// Looping Champion Query
$world_query = mysql_query("select * from championship where belt=1 ORDER BY `datewon` ASC ");
while ($wdisplay = mysql_fetch_array($world_query)) {
if ($wdisplay[datelost] == 0) {
$datetotal = "???"; } else {
$datetotal = ($wdisplay[datelost] - $wdisplay[datewon]) / 86400;
$datehours = $datetotal / 3600;
$datetotal = floor($datetotal); }
$datewon = date("M j, Y, g:i a", $wdisplay[datewon]);
if ($wdisplay[datelost] == 0) {
$datelost = "-"; } else {
$datelost = date("M j, Y, g:i a", $wdisplay[datelost]);
}
$user_info = mysql_fetch_array(mysql_query("select * from user where id = '".intval($wdisplay[champid])."'"));
echo "<tr><td>$datewon</td><td><a href='member.php?id=$user_info[id]'>$user_info[username]</a></td><td>$datelost</td><td>$datetotal Days $datehours Hours</td></tr>";
}
All i am trying to do is sucessfully calculate the amount of dates a person's total reign was. So I take the date lost subtracted by the date won to get a total. I store all dates in the db as an integer number. When it ouputs though at times it is not calculating the correct number of dates like for example I had one person win on the 27th of February and lost on the 6 of March and it says they have held for only 6 days... :bemused: Also for my number of hours I want to take my remainder after I just calculated the number of days and use that and round downward to the amount of hours but my hours are 100% not even calculating close and returning one long decimal number. Any idea how to get the # of days to calculate on everything as well as get the hours to actually calculate even somewhat correctly?