我有一張表(「場地」),用於存儲志願者可以工作的所有可能場地,每名志願者都分配給每個場地工作一個場地。從數據庫表中填充選擇下拉列表
我想從場地表中創建一個選擇下拉列表。
現在我可以顯示每個志願者分配的場地,但我希望它顯示下拉框,列表中已經選擇了場地。
<form action="upd.php?id=7">
<select name="venue_id">
<?php //some sort of loop goes here
print '<option value="'.$row['venue_id'].'">'.$row['venue_name'].'</option>';
//end loop here ?>
</select>
<input type="submit" value="submit" name="submit">
</form>
例如,具有7的ID志願者,被分配給venue_id 4
<form action="upd.php?id=7">
<select name="venue_id">
<option value="1">Bagpipe Competition</option>
<option value="2">Band Assistance</option>
<option value="3">Beer/Wine Pouring</option>
<option value="4" selected>Brochure Distribution</option>
<option value="5">Childrens Area</option>
<option value="6">Cleanup</option>
<option value="7">Cultural Center Display</option>
<option value="8">Festival Merch</option>
</select>
<input type="submit" value="submit" name="submit">
</form>
Brochure Distribution option will already be selected when it displays the drop down list, because in the volunteers_2009 table, column venue_id is 4.
我知道它將採取的形式爲或while循環拉從場地的列表場館表
我的查詢是:
$query = "SELECT volunteers_2009.id, volunteers_2009.comments, volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.choice3, volunteers_2009.lname, volunteers_2009.fname, volunteers_2009.venue_id, venues.venue_name FROM volunteers_2009 AS volunteers_2009 LEFT OUTER JOIN venues ON (volunteers_2009.venue_id = venues.id) ORDER by $order $sort";
如何填充選擇下拉框機智h場館表(volunteers_2009.venue_id,venues.id)從場館列表中選擇,並預先選擇列表中的場地?
我有一個表,存儲所有的場館(ID,venue_name) 的venues.id存儲在volunteers_2009表(場地)(volunteers_2009.venue_id) – Brad 2008-10-14 02:02:00