我已将选择下拉菜单中的苹果值保存到mysql中。 现在在编辑页面中,我想显示相应的值。 但我似乎没有把它弄好
<?php $food = $mysqli->real_escape_string($_POST['food']); ?>
<select id="food" required name="food" >
<option value="" disabled selected>Select a Food</option>
<option value="apple" <?php if($food == apple)
echo "selected='selected'"; ?>Apple</option>
<option value="kiwi" <?php if($food == kiwi)
echo "selected='selected'"; ?>Kiwi</option>
</select></div>
&#13;
答案 0 :(得分:0)
<select id="food" required name="food" >
<option value="" >Select a Food</option>
<option value="apple" <?php if($food == "apple")
echo "selected='selected'"; ?>Apple</option>
<option value="kiwi" <?php if($food == "kiwi")
echo "selected='selected'"; ?>Kiwi</option>
</select></div>
&#13;
答案 1 :(得分:0)
single
应附加double
引号或if($food == 'apple')
引号<select id="food" required name="food" >
<option value="" disabled selected>Select a Food</option>
<option value="apple" <?php if($food == 'apple')
echo "selected='selected'"; ?>Apple</option>
<option value="kiwi" <?php if($food == 'kiwi')
echo "selected='selected'"; ?>Kiwi</option>
</select></div>
$query = Doctrine_Query::create()
->from('attendanceRecord a')
->whereIn('a.employeeId', $employeeId);