我有来自select query的下拉列表。对于服务获得预订的特定日期意味着我想在下拉列表中禁用该服务我该怎么做
$query = "SELECT Services,Amount from wp_inside_mandir WHERE Status='Active' ";
$result = mysql_query ($query);
echo "<option value='0'>------------Choose Service----------</option>";
while($r = mysql_fetch_array($result))
{
echo '<option value="'.$r['Services'].'" data-time='.$r['Amount'].'>'.$r['Services'].'-'.$r['Amount'].'</option>';
}
我想要禁用此查询的服务结果(从wp_pooja_services中选择服务,其中Date =&#39; $ date&#39;和Location =&#39; Inside&#39;和Payment_Status!=&#39;已取消& #39;)
答案 0 :(得分:0)
尝试使用下面的代码段来按条件
禁用选项$disabledFlag = (condition) ? 'disabled="disabled"' : '' ;
echo '<option value="'.$r['Services'].'" data-time='.$r['Amount']. ' ' . $disabledFlag >'.$r['Services'].'-'.$r['Amount'].'</option>';
答案 1 :(得分:0)
将disabled="disabled"
添加到您要禁用的选项。
示例:
<option <?php if($row['foo']!="Some option"){echo "disabled="disable"}?> >Hello World</option>