Okay, I'm running out of ideas. This will automatically load today as the default. I'm not sure if it fixed the other problem or not. Please let me know. I can not reproduce your problem....so...I dont know if its fixed until you tell me. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <? $db_server="localhost"; $db_user="flightsched"; $db_password="jan1379"; $db_name="flightsched"; $link = mysql_connect($db_server, $db_user, $db_password) or die("Could not connect"); mysql_select_db($db_name) or die("Could not select database"); function CreateDateSelect($Days) { //creates a select box with the last $Days number of days; $SelectBox = "<select name='date'>"; $StartDate = date("Ymd", strtotime("-$Days days")); $EndDate = date("Ymd"); $RunningDate = $StartDate; while($RunningDate < $EndDate) { $SelectBox.="<option value='".$RunningDate."'"; if($RunningDate == $_GET['date']) $SelectBox.=" selected='selected'"; $SelectBox.=">".date("Y-m-d", strtotime($RunningDate))."</option>"; $RunningDate = date("Ymd", strtotime($RunningDate . " + 1 day")); } $SelectBox.="</select>"; return $SelectBox; } if((isset($_GET['date'])) || (isset($_GET['month'])) || (isset($_GET['forever']))) { $ReportData = array(); //initialize report data array //initialize the query $Query = "SELECT COUNT(idx) AS imagect, SUM(kb) AS bandwith FROM imagehits"; if(isset($_GET['date'])) { //Append where string $Query.=" WHERE DATE_FORMAT(timestamp, '%Y%m%d') = \"{$_GET['date']}\""; $ReportData['period'] = "Report for " . date("l, F jS, Y", strtotime($_GET['date'])) . ":"; } elseif(isset($_GET['month'])) { //Append where string $Query.=" WHERE MONTH(timestamp) = \"{$_GET['month']}\""; $ReportData['period'] = "Report for the month of " . date("F", mktime(0,0,0,$_GET['month'])).":"; } else { //Looking at forever doesn't require a where statement //Lets get the earliest date in the database $GetDate = "SELECT DATE_FORMAT(MIN(timestamp), '%Y-%m-%d') AS firstdate FROM imagehits"; $link = mysql_connect($db_server, $db_user, $db_password) or die("Could not connect"); mysql_select_db($db_name) or die("Could not select database"); $Result = mysql_query($GetDate) or die("Error executing query. MySQL Error: " . mysql_error()); $Row = mysql_fetch_assoc($Result); $ReportData['period'] = "Report data starting ". date("l, F jS, Y", strtotime($Row['firstdate'])) . " Till Today"; mysql_close($link); unset($Result,$Row); } } else {//if nothing is set, lets create the same query for TODAY $Query = "SELECT COUNT(idx) AS imagect, SUM(kb) AS bandwith FROM imagehits"; $Query.=" WHERE DATE_FORMAT(timestamp, '%Y%m%d') = \"".date("Y-m-d")."\""; $ReportData['period'] = "Report for " . date("l, F jS, Y") . ":"; } //Lets execute the query once and put it into an array $link = mysql_connect($db_server, $db_user, $db_password) or die("Could not connect"); mysql_select_db($db_name) or die("Could not select database"); //echo $Query . "<br />\r"; $Result = mysql_query($Query) or die("Error executing query. MySQL Error: " . mysql_error()); $Row = mysql_fetch_assoc($Result); $ReportData['countofhits'] = $Row['imagect']; $ReportData['bw_gb'] = $Row['bandwith'] / 1073741824; $ReportData['bw_kb'] = $Row['bandwith'] / 1024; $ReportData['bw_mb'] = $Row['bandwith'] / 1048576; $ReportData['bw_bytes'] = $Row['bandwith']; mysql_close($link); ?> <!--form section--> <div align='center'> <form name='reports' action='<? echo $_SERVER['PHP_SELF']; ?>' method='GET'> <a href="<? echo $_SERVER['PHP_SELF']; ?>?date=<? echo date("Ymd"); ?>">Today</a> - <a href="<? echo $_SERVER['PHP_SELF']; ?>?date=<? echo date("Ymd", strtotime("-1 day")); ?>">Yesterday</a> - <a href="<? echo $_SERVER['PHP_SELF']; ?>?month=<? echo date("m"); ?>">This Month</a> - Select a Date: <? echo CreateDateSelect(7); ?> <input type='submit' value='Go' name='submit' /> - <a href="<? echo $_SERVER['PHP_SELF']; ?>?forever=true">All Time</a> </form> </div> <!--Report Section--> <? if(isset($ReportData)) { ?> <table border="0" align="Center" cellpadding="4" cellspacing="0"> <tr> <td colspan='2'><? echo $ReportData['period']; ?></td> </tr> <tr> <td><strong>Image Hits:</strong></td> <td><? echo $ReportData['countofhits']; ?> Hits</td> </tr> <tr> <td><strong>Bandwith (GB):</strong></td> <td><? echo number_format($ReportData['bw_gb'], 2); ?> GB</td> </tr> <tr> <td><strong>Bandwith (MB):</strong></td> <td><? echo number_format($ReportData['bw_mb'], 2); ?> MB</td> </tr> <tr> <td><strong>Bandwith (KB):</strong></td> <td><? echo number_format($ReportData['bw_kb'], 0); ?> KB</td> </tr> <tr> <td><strong>Bandwith (Bytes):</strong></td> <td><? echo number_format($ReportData['bw_bytes'], 0); ?> B</td> </tr> </table> <? } ?> </body> </html> PHP: I've attached the file to make it a little easier to read thru.
loooooooooooooooool the box of dates is now fine and when i choose date from it, it shows it's stats properly but it's still not showing todays stats as default when i enter the page i'm satisfied with what you gave me, if you have some time, do it - if not then it's ok thanks alot
Yeah, I'm dumb, sorry about that...at line 81 replace this: $Query.=" WHERE DATE_FORMAT(timestamp, '%Y%m%d') = \"".date("Y-m-d")."\""; PHP: with this: $Query.=" WHERE DATE_FORMAT(timestamp, '%Y%m%d') = \"".date("Ymd")."\""; PHP: I think we've got it!