Need to select all entries for todays date
Posted: Fri Apr 09, 2010 10:13 am
personal accounting program - I need to get the sum of all the entries (mysql table) for today.
the date is inserted into the table in a date("Y-m-d") format
the table fields are id, date (type date) and amount
the code
the date is inserted into the table in a date("Y-m-d") format
the table fields are id, date (type date) and amount
the code
Code: Select all
$current_date = date("Y-m-d");
$day_sum = day_sum($current_date);
function day_sum($today) {
$q = " SELECT SUM(total) ";
$q .= " AS sum_total";
$q .= " FROM session";
$q .= " WHERE date=". $today ."";
$r = mysql_query($q, $c);
confirm_query($r);
$day_sum = mysql_fetch_array($r);
return $day_sum['sum_total'];
}