marksie1988 Posted August 6, 2008 Share Posted August 6, 2008 i have the below function but the mysql query doesn't seem to work, i want it to select all of the specific users logged miles (userid='$userid') and then select the ones between a date range and add them up. so if todays date was 05/08/08 it would remove 2629744 from the unix timestamp (30 days) and then this would be the date range from 5/07/08 to 05/08/08 once the date range is set it would find the rows with the userid and the date range and then add all the results miles together. below is the code please help, currently the mysql query just adds all of the miles in that date range function MilesDoneMTD($userid, $date){ $curdate = $date - (2629744); $mdytd = "SELECT sum(miles) FROM mileage WHERE userid='$userid' AND datedone BETWEEN '".$curdate."' AND '".$date."' GROUP BY userid"; $mdytdr = mysql_query($mdytd); $rows = mysql_fetch_array($mdytdr); echo "Miles Done MTD: ".$rows['sum(miles)'].""; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.