I'm not sure how to explain . Its confusing to me as I'm still a newbie in this php world. Hope you guys can help me.
I have a form. In that form there are two dropdown list. The first dropdown list will display all the location that have been save in database. The problem is that how can I, display the id number in the second dropdown list based on the location that have been selected in the first dropdown list .
Can anyone help me ?
Code:
<form action="form.php" method="post" name="order">
<table>
<tr>
<td>Select Location :</td>
<td> <select name="location" id="location">
<option>-- Location --</option>
<?php
$query="SELECT DISTINCT location FROM inventory";
$result=mysql_query($query);
while(list($locationid)=mysql_fetch_row($result)) {
echo "<option value="".$location."">".$location."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Date :</td>
<td><input type="text" nama="date" /></td>
</tr>
<td>Id Number:</td>
<?php
$query="SELECT DISTINCT idno FROM asset WHERE locationid='inventory.location'";
$result=mysql_query($query);
while(list($idno)=mysql_fetch_row($result)) {
echo "<option value="".$idno."">".$idno."</option>";
}
?>
</td>
</tr>
<tr><td>
<input type="button" value="submit" name="submit" /> </td></tr>
</table>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…