sorry. wife walked in ..... 🙂
haven't tested this, but I think it should work:
<?
include("dbconnect.php") // your connection arguments to mysql where $mysql_link will be the connecting string for later use
$query = "select * from weather where temp > 70";
$result = mysql_query($query, $mysql_link);
while($row = mysql_fetch_row($result))
{
$mktime = explode("-", $row[0]); // where $row[0] is the date
$time[] = mktime(0,0,0,$mktime[1], $mktime[2], $mktime[0]); // where date is 2003-08-26
}
$firstmatch = 0;
$cons = 0;
$count = '';
$firstmatch = 0;
for($i=0; $i<count($time); $i++)
{
$first = $time[$i]; $i++;
$second = $time[$i]; $i--;
$third = ($second - $first);
if($third == 86400)
{
$cons++;
$count .= "$i,";
}
else
{
if($cons > $firstmatch)
{
$firstmatch = $cons;
$days = $count;
}
$cons = 0;
$count = '';
}
}
$dates = explode(",", $days);
echo "There are $firstmatch consecutive days above 70<br><br>";
echo "They are:<br>";
foreach($dates as $v)
{
$newdate = date("M-d-Y", $time[$v]);
echo "$newdate<br>";
}
?>