Going back to my example I posted earlier,
$times is a PHP array you create and is permanent, written as PHP.
$booked is an array which is generated from the sql select I posted for you, you’d perhaps normally call it $rows in this manner:
(code lifted from the manual for mysql_fetch_array)
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$qry = "select concat( HOUR(updated) , ':', MINUTE(updated)) as daytime from
mytable where DATE(updated) = '2011-05-25'";
$result = mysql_query($qry);
$rows = mysql_fetch_array($result, MYSQL_NUM))
// but use:
// $booked = mysql_fetch_array( ... );
Then join the 2 arrays as I showed you.
And, yeah, of course add ‘checked’, like so:
foreach( $display_times as $key=>$value ) {
$checked = ($value == 'booked') ? 'checked=checked':'';
echo "<li><input type=checkbox value='$key' $checked /> $key is $value </li>" . PHP_EOL;
}
Edit:
Sorry, just realised that I am using the var name $times in two places, how very confusing that must be. Change it to this:
$times = array(
'10:00' => 'free',
'10:30' => 'free',
'11:00' => 'free',
'11:30' => 'free',
);
$booked = array(
'10:30' => 'booked',
);
$display_times = array_merge($times, $booked);
So $display_times is the 3rd array, the sum of $times and $booked, I have amended the original code for this particular post.