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);
// 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";