Jump to content

[SOLVED] mm select problem with php quite tricky


shadiadiph

Recommended Posts

Hi I have the following php form the second selection item has to relate to the first selection item but i am totally lost here here is the code i have at the moment it is displaying items in the second selection but they are not related to the first item selected.

 

<td class="right">

<?

$sql = "SELECT * FROM tblcatdetails ORDER BY category ASC";

$result = mysql_query($sql);

echo '<select name="category">';

while ($row = mysql_fetch_assoc($result)) {

$catid = $row["intCatID"];

$category = $row["category"];

echo '<option value="'.$catid.'">'.$category.'</option>';

}

echo '</select>';

?>

 

</td></tr>

<tr><td class="left">Sub Category:</td>

<td class="right">

<?

$sql = "SELECT * FROM tblsubcatdetails where intCatID='$catid' ORDER BY subcategory ASC";

$result = mysql_query($sql);

echo '<select name="subcategory">';

while ($row = mysql_fetch_assoc($result)) {

$subcatid = $row["intSubCatID"];

$subcategory = $row["subcategory"];

echo '<option value="'.$subcatid.'">'.$subcategory.'</option>';

}

echo '</select>';

?>

</td></tr>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.