drop down menu from database
Posted: Mon Sep 15, 2008 7:10 am
Code: Select all
<td><select name="Select2">
<?php
// SQL query to select the rows
$queryC = "SELECT * FROM TblCat ";
$resultC = mysql_query ($queryC);
while($rowC = mysql_fetch_array($resultC,MYSQL_ASSOC))
{
Echo '<option value="' . $rowC[Id] . '">' . $rowC[catName] . '</option>';
$items = $rowC[Id];
}
?>
</select></td>
</tr>
<tr>
<td style="width: 148px">Sub-Category </td>
<td><select name="Select3">
<?php
// SQL query to select the rows
$querySC = "SELECT * FROM TblSubCats WHERE main = '$items'";
$resultSC = mysql_query ($querySC);
while($rowSC = mysql_fetch_array($resultSC,MYSQL_ASSOC))
{
Echo '<option value="' . $rowSC[id] . '">' . $rowSC[sub] . '</option>';
}
?>
</select> </td>
1 has main cat and the 2nd has sub cat
i want the code to look at what they select in box1 and then in box2 only show the fields that have the same id as box1
if not making sence have a look at this
database table Cat has 2 fields Name, Id
Table subCat has fileds Id and then catId
when the user selects item 1 in cat dropdown menu it shoul show all the items that have the same catId in subCat table
Thanks