Dependent Dropdown php/mysql/java
Hi,
Im kinda new to php/mysql programming and I was hoping I could get some help with this. I am trying to create 2 dependent dropdown menus. gThe first one dictate the content of the second one. I hot the connection right but once the second menu loads I could scroll down the list but nothing it is showing on it. ike i cant see the fonts. I read the page source and it is showing the options on it.
Any help I would greatly appreciate.
Here it is the code:
$category = $item = null; //declare vars
$conn = mysql_connect($server,$user,"");
$db = mysql_select_db('sin',$conn);
if(isset($_GET["category"]) && is_numeric($_GET["category"]))
{
$category = $_GET["category"];
}
if(isset($_GET["item"]) && is_numeric($_GET["item"]))
{
$item = $_GET["item"];
}
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<form name="theForm" method="get">
<p>
</p>
<table width="200" border="1">
<tr>
<td>Select Category</td>
</tr>
<tr>
<td><select name="category" onchange="autoSubmit();">
<option value="null"></option>
<option value="199" <?php if($category == 199) echo " selected"; ?>>Hydraulics</option>
<option value="299" <?php if($category == 299) echo " selected"; ?>>Electronics</option>
</select></td>
</tr>
<tr>
<td>Select Item</td>
</tr>
<tr>
<td>
<div align="center" class="style2 style3">
<select name="item" onchange="autoSubmit();">
<option value="1">select Here</option>
<?php
//POPULATE DROP DOWN MENU WITH COUNTRIES FROM A GIVEN REGION
$sql = "SELECT cat, desc_p FROM parts WHERE cat <= $category";
$items = mysql_query($sql,$conn);
while($row = mysql_fetch_array($items))
{
echo ("<option value=\"$row[desc_p]\" " . ($item == $row["desc_p"] ? " selected" : "") . ">$row[dec_p]</option>");
}
?>
</select>
</div></td>
</tr>
</table>
<p><br>
</p>
</form>
|