0
<select id="section" name="section">
<?php
include("Nethost.php");
$section = "";
$yr = "";
$sql = mysql_query("SELECT DISTINCT * FROM section ORDER BY yrlvl, section");
while ($row = mysql_fetch_array($sql)){
$section = $row['section'];
$yr = $row['yrlvl'];
?>
<option value="">Select</option>
<option <?php $result2 = mysql_query("SELECT section FROM student WHERE idnumber = '$idnumber'");
if(mysql_num_rows($result2) > 0) { ?>
selected="selected" <?php } ?> value="<?php print $section; ?>"><?php print $yr; ?> - <?php print $section; ?></option>
<?php } ?>
</select>
以上是select選項的php代碼。從數據庫表填充數據,如何將第一個值設置爲空。我嘗試添加一個選擇,但這是結果。將動態HTML選項的第一個值設置爲空
選項選擇不斷重複。該怎麼做?
仙。只是把它放在while循環之外。謝謝。 – eirishainjel
:)雅,如果這解決了您的問題,請記住標記答案正確 – Baig
是的。我仍然有一分鐘將它標記爲答案。謝謝。 – eirishainjel