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
36
Other forums
how do i make a string??
hey guys,
can someone please tell me how to put data from the glob function into a string
Include with Parameters
In a particular page I would like to include a file that requires $_GET parameters.
when I go
Pop-up Banner
Hello Friends,I need to use banner in our client site.Example: www.example.com if i enter this site
Undefined variable when using $_SERVER['PHP_SELF']
Hi guyz, please suggest me something...
On first.php I have one input field NAME, and on posting
validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners
Select Lists into MYSQL
Hello All, I am new to PHP @ 1 week. So borrowing code anywhere I can. I am making progress, but h
When file included, REMOTE_ADDR is server's?
I have an index file that handles my site, basically index.php?page=ip will activate "require('
utl_file open error
i have file in the unix path
Path /popdev01/pop/popdevb/tfi/
File name
Need help with PHP/MySQL drop down menu
I need help on how I can implement a drop down menu which queries mysql database and output the avai
Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...