This is the code i'm talking about
session_start();
include ('configg.php');
$query = "SELECT Date, Time FROM gp_appointment WHERE Name = '$_POST[doctor]' AND Date = '$_POST[date]'";
$result = mysql_query($query);
$data = array();
while($row = mysql_fetch_assoc($result))
{
$data[] = $row;
}
$colNames = array_keys(reset($data))
?>
<table border="1">
<tr>
<?php
//print the header
foreach((array)$colNames as $colName)
{
echo "<th>$colName</th>";
}
?>
</tr>
<?php
//print the rows
foreach((array)$data as $row)
{
echo "<tr>";
foreach($colNames as $colName)
{
echo "<td>".$row[$colName]."</td>";
}
echo "</tr>";
}
?>
</table>
<a href="homepage.php">Go back to the homepage</a><br>
<a href="docname.php">Check another doctor</a><br>
When i chose a date that exist in the databse all works fine, but if a choose a date not-existent i recieve this error:
Warning: array_keys() expects parameter 1 to be array, boolean given in H:\Project\xampplite\htdocs\example\phptutorial\doctorav.php on line 15
Somebody know what to do?