Hello, okay I have lets just say I have 3 tables in a database one called "id" (auto-incrementing, Key thing-a-jig) "date", and one called "hits".
Date is formatted as Year-month-day, hits is an integer.
I want to grab only the Rows that are from "Today" and then cacluate the "hits" to a total numbers.
So say you pull out of the database
id:1 date:2009-09-09 hits:200
id:2 date:2009-09-09 hits:100
id:3 date:2009-09-09 hits:100
= 400 hits.
How I can calculate all those 3 to a total number?
Here is my code thus far.
if(!$smarty->is_cached('index.tpl')) {
$results = array();
$link = mysql_connect($CONFIG['mysql_host'],$CONFIG['mysql_user'], $CONFIG['mysql_pass']) or die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db($CONFIG['mysql_db'],$link) or die('Could not contact the database');
//Get Todays Date in year-month-day
$date = date("Y-m-d");
// Only grab the rows where the date = today's $date.
$Hits = mysql_query('SELECT * FROM links WHERE date=' . $date . ' ORDER BY id DESC LIMIT 0,500') or die('Could not connect: ' . mysql_error());
while ($line = mysql_fetch_assoc($Hits)) {
$tmp[] = $line;
}
/// Begin Math problem to calculate the hits....?
}