I have a question and I think there is a really easy solution for, but i'm busy for 12 hours now and I don't know the solution for this problem.
I have a database with several data. The important data is the time that I save in the database. I want to build a module that give the data 08:00 to 17:00. For example:
08:00 available 09:00 not available 10:00 available 11:00 available 12:00 available 13:00 available 14:00 available 15:00 available 16:00 available 17:00 not available
I'll using the following code
$mysql['avail'] = mysql_query("SELECT time FROM `module` WHERE `date` = '" . $dbdate . "' ORDER BY date");
while($avail = mysql_fetch_assoc($mysql['avail'])){
$hour = date('s',$avail['time']);
for ($i = 8;$i <= 17; $i++) {
if($hour == $i) {
echo $i.':00 not available<br />';
} else {
echo $i.':00 available<br />';
}
}
}
Now I get the following output:
08:00 available 09:00 not available 10:00 available 11:00 available 12:00 available 13:00 available 14:00 available 15:00 available 16:00 available 17:00 available 08:00 available 09:00 available 10:00 available 11:00 available 12:00 available 13:00 available 14:00 available 15:00 available 16:00 available 17:00 not available
Whatever I try, I've no solution to get it right. Is there anybody that can help me?
See Question&Answers more detail:os