<?php
$host="localhost";
$uname="rooms";
$pass="";
$database="Rooms";
$tablename="Reservations";
$connection= mysql_connect($host,$uname,$pass)
or die("<br> DataBase Connection Failed! <br>");
$result=mysql_select_db($database)
or die("<br> DataBase Could not be selected <br>");
$query = "select ReserveDate, EndTime, StartTime FROM Reservations, ReserveDates WHERE (Reservations.Id = ReserveDates.Id) AND (Room='442') AND (ReserveDate BETWEEN '2003-01-01' AND '2003-01-01') AND (Comments='' OR Comments='442')";
$result= mysql_query($query);
$num_results = mysql_num_rows($result);
$j=0;
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
list($hour,$minute,$second) = explode(":",$row[2]);
list($hour1,$minute1,$second1) = explode(":",$row[1]);
if ($minute1 != '00')
{
$correct = $hour1;
}
else
{
$correct = ($hour1-1);
}
//echo" $correct, $hour \n";
$a = $hour;
$a = ereg_replace("0([0-9]+)", "\1", $a);
$b = $correct;
while ($a <= $b)
{
$room108[$j] = $a++;
echo "\n";
$j++;
}
}
$c_arr = array_count_values($room108);
$header_array = array("7am"=>"7", "8am"=>"8", "9am"=>"9", "10am"=>"10", "11am"=>"11", "12Noon"=>"12", "1PM"=>"13","2PM"=>"14", "3PM"=>"15", "4PM"=>"16", "5PM"=>"17", "6PM"=>"18", "7PM"=>"19", "8PM"=>"20", "9PM"=>"21", "10PM"=>"22", "11PM"=>"23");
foreach($header_array as $x=>$y)
{
if(array_key_exists($y,$c_arr)){
print $x . ' occured ' . $c_arr[$y]. ' times<br>';
//print $x . " occured" . $c_arr[$y]."<BR>";
}
else
{
print $x ." --<BR>";
}
}
?>
After the query is executed if the result is empty set then i have a problem
The warning messages I am getting are
Warning: Argument to array_count_values() should be an array in /home/rooms/htdocs/statistics/testing3.php on line 44
Warning: Wrong datatype for second argument in call to array_key_exists in /home/rooms/htdocs/statistics/testing3.php on line 49
7am --
So help me with this code