<table style="border: 1px solid;">
<thead>
<tr>
<td style="border:1px solid;padding:11px;">Time</td>
<td style="border:1px solid;padding:11px;">Book</td>
</tr>
</thead>
<tbody>
<?php
$starttime = $query2['starttime']; // your start time
$endtime = $query2['endtime']; // End time
$duration = '30'; // split by 30 mins
echo "Availability Timing :- "; echo $starttime;echo " to " ;echo $endtime;
echo "<span style='color:red;'>"; echo "<br>Availability Days :- "; echo $query2['days']; echo "</span>";
//echo "<br>Select Date :- "; echo $_POST['date'];
$array_of_time = array ();
$start_time = strtotime ($starttime); //change to strtotime
$end_time = strtotime ($endtime); //change to strtotime
//echo $single_time; <?php echo current($array_of_time); echo " - ";echo next($array_of_time); echo '<br>';
$add_mins = $duration * 60;
while ($start_time <= $end_time) // loop between time
{
$array_of_time[] = date ("h:i a", $start_time);
$start_time += $add_mins; // to check endtime
}
$arr_ctr=count($array_of_time)-1;
foreach ($array_of_time as $key => $single_time) {
if($arr_ctr>$key){
?>
<tr>
<td style="border:1px solid;padding:11px;">
<?php
$query5=mysql_query("select * from doctorbooking where aday='2016-09-29' and demail='".$query2['email']."'");
$query6=mysql_fetch_array($query5);
//echo $query6['atime'];
//var_dump($query6);
if (($array_of_time[$key] . ' - ' . $array_of_time[$key+1])==$query6['atime'])
{
echo $array_of_time[$key] . ' - ' . $array_of_time[$key+1] . '<br /><span style="color:red;background-color:#C0C0C0;">Booked</span>';
} else
{
echo $array_of_time[$key] . ' - ' . $array_of_time[$key+1] . '<br /><span style="color:red;">Available</span>';
}
?>
</td>
<td style="border:1px solid;padding:11px;">
<input type="radio" value="<?php echo $array_of_time[$key].' - '.$array_of_time[$key+1]; ?>" id="A" name="A"></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
The problem is that i want to select atime column from the database by selecting particular mail id and date.I have 4 values of atime in the database but it is selecting only the first one,it is not selecting the others.I have check using //echo $query6['atime']; and I want to disable that radio button also if it is booked.
<?php
$array_filter = $array_of_time[$key] . ' - ' . $array_of_time[$key+1];
$is_booked = false;
$query5=mysql_query("select atime from doctorbooking where aday='2016-09-29' and demail='".$query2['email']."'");
//$query6=mysql_fetch_array($query5);
//echo $query6['atime'];
//var_dump($query6);
while( $query6 = mysql_fetch_array($query5) ) {
if ( $array_filter == $query6['atime'] ) {
//it force "booked" as soon as 1 is booked
$is_booked = true;
} else {
// OR uncomment here to force "available" as soon as 1 is availabe
//$is_booked = false;
}
}
if ($is_booked) {
echo $array_filter . '<br /><span style="color:red;background-color:#C0C0C0;">Booked</span>';
} else {
echo $array_filter . '<br /><span style="color:red;">Available</span>';
}
//mysql_data_seek($query5,0);
?>
this is the solution of this question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.