我正在从MySQL数据库中检索数据并将其爆炸,根据结果我想选择多个复选框,我粘贴我的PHP代码和所有复选框代码以及数据库,这样您就可以看到必须选择哪个复选框结果。
<?php
$query25 = "SELECT * FROM es_availability_options WHERE es_id='4'";
$result25 = @mysql_query($query25);
echo mysql_error();
$row25=@mysql_fetch_array($result25);
$availability_options = $row25['availability_options'];
$availability_options = explode(', ', $availability_options);
?>
<div class="row">
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available by appointment"> Available by appointment</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Pre bookings preferred but can be available at short notice"> Pre bookings preferred, but can be available at short notice</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Flexible hours by appointment"> Flexible hours by appointment</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available for overseas travel"> Available for overseas travel</p>
</div>
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 7 days"> Available 7 days</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="12 hours notice required"> 12 hours notice required</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available outside my city only"> Available outside my city only</p>
</div>
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 24 hours"> Available 24 hours</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="24 hours notice required"> 24 hours notice required</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available on weekends only"> Available on weekends only</p>
</div>
</div><!-- end row -->
我有“可用7天,需要12小时通知,仅在我的城市以外可用”数据库列“availability_options”中的这些选项。
答案 0 :(得分:0)
<div class="row">
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available by appointment"> Available by appointment</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Pre bookings preferred but can be available at short notice"> Pre bookings preferred, but can be available at short notice</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Flexible hours by appointment"> Flexible hours by appointment</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available for overseas travel"> Available for overseas travel</p>
</div>
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 7 days" <?php if (in_array("Available 7 days", $availability_options)) {echo "checked"; }?>> Available 7 days</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="12 hours notice required" <?php if (in_array("12 hours notice required", $availability_options)) {echo "checked"; }?>> 12 hours notice required</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available outside my city only" <?php if (in_array("Available outside my city only", $availability_options)) {echo "checked"; }?>> Available outside my city only</p>
</div>
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 24 hours"> Available 24 hours</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="24 hours notice required"> 24 hours notice required</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available on weekends only"> Available on weekends only</p>
</div>
答案 1 :(得分:0)
<div class="col-md-4">
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 7 days" <?php if(in_array('Available 7 days', $availability_options)) echo 'checked="checked"'; ?>> Available 7 days</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="12 hours notice required" <?php if(in_array('12 hours notice required', $availability_options)) echo 'checked="checked"'; ?>> 12 hours notice required</p>
<p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available outside my city only" <?php if(in_array('Available outside my city only', $availability_options)) echo 'checked="checked"'; ?>> Available outside my city only</p>
</div>