Display the user's weight lost in the past week


Posted on 16th Feb 2014 07:03 pm by admin

Hello everyone,

I am working on a weight loss app for my site, and I want to display the user's weight lost in the past week, I have the current weight and the total weight lost today working great, but I was at a loss on how to get the weight for the past week to work

Here is the code that I'm working with:Code: [Select]mysql_select_db($database_getfit, $getfit);
$query_getfit_xml = "SELECT * FROM jos_my_weight ORDER BY `date` DESC"; // DESC and ASC
$getfit_xml = mysql_query($query_getfit_xml, $getfit) or die(mysql_error());
$row_getfit_xml = mysql_fetch_assoc($getfit_xml);
$totalRows_getfit_xml = mysql_num_rows($getfit_xml);

// START WEIGHT
$start_weight = '230';

// GOAL WEIGHT
$goal_weight = '175';

$rows = array();
while($row = mysql_fetch_assoc($getfit_xml)):
$rows[] = $row;
endwhile;

$xml = '<?xml version="1.0" encoding="utf-8"?>'."n";
$xml .= '<chart>'."n";
$xml .= ' <chart_data>'."n";

// GET DATES
$xml .= ' <row>'."n";
$xml .= ' <null/>'."n";
foreach($rows as $row):
$xml .= '<string>'.$row['date'].'</string>'."n";
endforeach;
$xml .= ' </row>'."n";

// GET CURRENT WEIGHTS
$xml .= ' <row>'."n";
$xml .= ' <string>Current Weight</string>'."n";
foreach($rows as $row):
$xml .= '<number>'.$row['weight'].'</number>'."n";
endforeach;
$xml .= ' </row>'."n";

// GET TOTAL WEIGHT LOST TO DATE
$xml .= ' <row>'."n";
$xml .= ' <string>Total weight lost to date</string>'."n";
foreach($rows as $row):
$weight_lost = $start_weight - $row['weight'];
$xml .= '<number>'.$weight_lost.'</number>'."n";
endforeach;
$xml .= ' </row>'."n";

// GET WEIGHT LOST THIS WEEK
$xml .= ' <row>'."n";
$xml .= ' <string>Total weight lost to date</string>'."n";

$i = 0;
foreach($rows as $row):
$xml .= '<number>'.$row['weight'].'</number>'."n";
$i++;
endforeach;

$xml .= ' </row>'."n";

$xml .= ' </chart_data>'."n";
$xml .= '</chart>';

echo $xml;

mysql_free_result($getfit_xml);

No comments posted yet

Your Answer:

Login to answer
146 Like 36 Dislike
Previous forums Next forums
Other forums

Something like an INI editor or a DelimitedText-Editor
Hi all,

Am very, very, very new to PHP and not sure if I should be posting this to a Javascri

How would I protect......
I have a from, actually, a good amount of forms. How can I make it so you can't type the characters:

Question about the upload of large files
Hi there,

I have a question about the upload of large files, like videos (files generally abo

Help pulling in 'id' with "read more" link
I'm trying to create snippets of my articles in the cms I'm creating, and then have them redirect to

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

Weird MySQL error, why am I recieving this?
PHP Code:


<?php require "global_settings.php"; ?>
<titl

Is it possible to stop reservation creation in PM Order?
Hi All,

Is it possible to stop reservation creation in PM Order?

Thanks in adv

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

Help with syntax
Hi all!

The $bridge variable is not getting passed while it is contained in the line below:

Character Set Setup
Whats the best character set to use if you want every character to work, and also how do you make yo

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash