我有一個選擇框,我希望循環添加到數據庫。它看起來很適合我,但它不會進入數據庫。php mysql選擇框
<select name="countylist" style="height:300px;" class="multiple" multiple="multiple" id="box2View">
<option value="11">Beer Gardens</option><option value="10">Historic Bars</option>
<option value="8">Live Music</option><option value="1">Night Clubs</option>
<option value="4">Pubs Serving Food</option><option value="6">Sports Bars</option>
</select>
SQL:
foreach($_POST["countylist[]"] as $s) {
$insertSQL = sprintf("INSERT INTO cat_pubs (pub_id, cat_id)
VALUES(LAST_INSERT_ID(),". $s . ")");
mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
}
感謝
嘗試'的foreach($ _ POST [ 「countylist」])' – Armatus 2012-04-25 16:37:15
沒有不要麼反正工作,謝謝,但我敢肯定它是一個數組 – 2012-04-25 16:39:10
在HTML – BeRecursive 2012-04-25 16:41:14