我在 while 循环中有一组数据。当我在 while 循环数据中回显它们时,类似于此..
if ( !empty($rows) ) {
// bind variables to prepared statement
mysqli_stmt_bind_result($stmt, $userId, $days, $opentime, $closetime, $closestate);
while (mysqli_stmt_fetch ($stmt)) {
echo '<pre>', print_r("$days - $opentime - $closetime - $closestate").'</pre>';
}
}
数据 :
Monday - 06.00 PM - 06.00 PM - 0
Tuesday - 05.00 PM - 06.00 PM - 0
Wednesday - 05.00 PM - 05.00 PM - 0
Thursday - 05.00 PM - 05.00 PM - 0
Friday - 03.00 PM - 04.00 PM - 0
Saturday - 03.00 PM - 03.00 PM - 0
Sunday - 03.00 PM - 02.00 PM - 0
在while循环中,我想分离这样的数据..
$monOpen = // monday open time
$monClose = // monday close time
$monNo = // closed day
$tueOpen = // Tuesday open time
$tueClose = // Tuesday close time
$tueNo = // closed day
.............
and so on for 7 days..
为什么我需要这样做,以便在 while 循环之外使用这些值。
在while循环之外,我有一些像这样的下拉菜单和复选框 -
我的选择框 -
<select name="tuesday-open" class="text2">
<option>Open</option>
<?php for($i = 1; $i <= 24; $i++): ?>
<option value="<?php echo date("h.i A", strtotime("$i:00")); ?>" <?php if(isset($_POST['tuesday-open']) && $_POST['tuesday-open']==(date("h.i A", strtotime("$i:00")))) echo ' selected="selected"'; ?>><?php echo date("h.i A", strtotime("$i:00")); ?></option>
<?php endfor; ?>
</select>
我的复选框 -
<input type="checkbox" name="tuesday-closed" <?php if(isset($_POST['tuesday-closed'])) echo "checked";?> /> closed
所以我想在带有属性selected=selected
和checked
..的选择框和复选框中显示获取值
任何想法将不胜感激,也欢迎另一种方式。谢谢你。