[請益] PHP+MySQL 動態二階選單的Bug!!
各位高手好!
小弟目前在撰寫一個PHP的動態二階選單!!
以下是小弟的程式碼:
<html>
<body>
<form name="form1">
<p>
<select name="select1" onChange="document.form1.submit();">
<option selected>請選擇</option>
<?
include("func/link_db.php");
$sql="SELECT product_type FROM product_data GROUP BY product_type ORDER BY product_type";
$result=mysql_query($sql);
while ($row = mysql_fetch_row($result))
{
?>
<option>
<? echo $row[0]; } mysql_close($link); //關閉資料庫連接 ?></option>
</select>
</p>
</form>
<select name="select2">
<option selected>ALL</option>
<?
include("func/link_db.php");
$sql2="select * from product_data where product_type='$select1' and front_display='Y' group by supplier_id order by supplier_id";
$result2=mysql_query($sql2);
while ($row2 = mysql_fetch_row($result2))
{
?>
<option> <? echo $row2[2]; } mysql_close($link); //關閉資料庫連接 ?></option>
</select>
<input type="submit" name="Submit" value="送出">
</body>
</html>
目前的問題是...當我選擇select1的選項時,select2的資料有跟著改變!!但是select1又回到"請選擇"的地方!!
理論上select1應是要跑到我選的資料!!
請問各位大大我是不是哪裡寫錯了呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.70.67
推
08/03 19:05, , 1F
08/03 19:05, 1F
推
08/03 21:07, , 2F
08/03 21:07, 2F
推
08/03 22:12, , 3F
08/03 22:12, 3F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章