PHP/MySQL的獲取下拉的價值選擇
<div style="width:810px; margin:inherit; padding-left:170px;">
<select style="width:300px;" id="n" name="userListingCateory">
<option disabled="disabled">Category...</option>
<?php while($row = $sth2->fetch(PDO::FETCH_ASSOC))
{echo "<option value=". $row['catID'] . ">" .$row['catName']."</option>";}
unset($sth2);
?>
</select>
<select style="width:340px;" id="n" name="userListingSubCateory">
<option disabled="disabled">Sub-Category...</option>
<?php while($row = $sth3->fetch(PDO::FETCH_ASSOC))
{echo "<option value=". $row['scatID'] . ">" .$row['scatName']."</option>";}
unset($sth3);
?>
</div>
</select>
上面這個HTML獲取所有類別和子類別中的兩個表[Category]
和[SubCategory]
的PHP/MySQL的需要在點擊[Category]
下拉菜單後運行將看起來像:
SELECT scatID, scatName
FROM Category C, SubCategory SC
WHERE C.catID = SC.catID
AND C.catID = $origCatIDSelected;
我如何得到這個讓sub-categories
在此基礎上category
選擇?
是否有jQuery的/ PHP來實現任何簡單的方法?
感謝
你需要這個:http://stackoverflow.com/a/7137507/762449 – AlphaMale