The query is still slow. My page takes about a second to load without the following. With that in there it takes nearly 19 seconds. According to phpMyAdmin Showing rows 0 - 29 (73242 total, Query took 0.0018 sec) Each hour for now and until the end of the calendar year, 100 records are added. For a total of about 876,000 at Decmeber 31.
It must be all these operations that I perform on the data slowing it down. This is why I wish there was a way to just grab the most recent record for each FMFP_ID and do those calculations on it.
if (!$link = mysql_connect('localhost', 'uuuu', 'ppppp'))
exit("Unable to make a connection to the database");
if (!mysql_select_db("ops_db", $link))
exit("Unable to select the database");
$array = array ();
$result = mysql_query('SELECT * FROM Actual_Hourly_2004 ORDER BY Date_Valid, Time_Valid ASC');
while ($row = mysql_fetch_assoc ($result))
{
extract ($row);
$array[$FMFP_ID] = array ('Temp' => $Temp, 'RH' => $RH, 'Time_Valid' => $Time_Valid, 'Date_Valid' => $Date_Valid, 'CDir' => $CDir, 'WSpd' => $WSpd, 'WGst' => $WGst, 'Rn_1' => $Rn_1);
$array[$FMFP_ID]['Time_Valid']= ereg_replace(":00:00",":00 CST",$array[$FMFP_ID]['Time_Valid']);
if ($array[$FMFP_ID]['Temp'] == -99.9){$array[$FMFP_ID]['Temp'] = "N/A";}
else {$array[$FMFP_ID]['Temp'] = $array[$FMFP_ID]['Temp']."°C";}
if ($array[$FMFP_ID]['RH'] == -99.9){$array[$FMFP_ID]['RH'] = "N/A";}
else {$array[$FMFP_ID]['RH'] = round($array[$FMFP_ID]['RH'])."%";}
if ($array[$FMFP_ID]['CDir'] == "MMM"){$array[$FMFP_ID]['CDir'] = "N/A";}
if ($array[$FMFP_ID]['WSpd'] == -99.9){$array[$FMFP_ID]['CDir'] = "N/A";}
if (($array[$FMFP_ID]['CDir'] != "N/A") && ($array[$FMFP_ID]['WSpd'] != -99.9) && ($array[$FMFP_ID]['WGst'] == -99.9)){$array[$FMFP_ID]['CDir'] = $array[$FMFP_ID]['CDir']." ".round($array[$FMFP_ID]['WSpd'])." km/h";}
if (($array[$FMFP_ID]['CDir'] != "N/A") && ($array[$FMFP_ID]['WSpd'] != -99.9) && ($array[$FMFP_ID]['WGst'] != -99.9)){$array[$FMFP_ID]['CDir'] = $array[$FMFP_ID]['CDir']." ".round($array[$FMFP_ID]['WSpd'])." G".round($array[$FMFP_ID]['WGst'])." km/h";}
if ($array[$FMFP_ID]['Rn_1'] == 0.0){$array[$FMFP_ID]['Rn_1'] = "Not reported";}
if ($array[$FMFP_ID]['Rn_1'] != 0.0){$array[$FMFP_ID]['Rn_1'] = $array[$FMFP_ID]['Rn_1']."mm in the past hour";}
$array[$FMFP_ID]['Date_Valid']=substr($array[$FMFP_ID]['Date_Valid'], 4);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-01-","Jan-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-02-","Feb-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-03-","Mar-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-04-","Apr-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-05-","May-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-06-","Jun-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-07-","Jul-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-08-","Aug-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-09-","Sep-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-10-","Oct-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-11-","Nov-",$array[$FMFP_ID]['Date_Valid']);
$array[$FMFP_ID]['Date_Valid']=ereg_replace("-12-","Dec-",$array[$FMFP_ID]['Date_Valid']);
}