Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Drop Down Menu

Status
Not open for further replies.

tshey

Technical User
Dec 28, 2005
78
AU
I have two dynamic drop down menus that contain two tables category and brand. I want to be able to select a value in each drop down menu and have the value passed through the url to select a specific item that corresponds to these two parameters. This is what I have for the page to be sent. It is not choosing the values, what am I doing wrong:
I have done this in dreamweaver as you can see


<body>
<div id="pagecell">
<div id="border">
<div id="head">Delete Product</div>
<div id="cleanercontent">
<p>Select the brand of the item you wish to delete. </p>
<form name="form1" id="form1" method="get" action="delete_citem.php">
<table width="100%" border="0">
<tr>
<td>Brands:</td>
<td><select name="brand_id">
<?php
do {
?>
<option value="<?php echo $row_brands['brand_id']?>"<?php if (!(strcmp($row_brands['brand_id'], $row_brands['brand_id']))) {echo "SELECTED";} ?>><?php echo $row_brands['brand_title']?> <?php echo $row_brands['brand_id']; ?> </option>
<?php
} while ($row_brands = mysql_fetch_assoc($brands));
$rows = mysql_num_rows($brands);
if($rows > 0) {
mysql_data_seek($brands, 0);
$row_brands = mysql_fetch_assoc($brands);
}
?>
</select>
</td>
</tr>
<tr>
<td>Category:</td>
<td> <select name="id">
<?php
do {
?>
<option value="<?php echo $row_category['id']?>"<?php if (!(strcmp($row_category['id'], $row_category['cat_id']))) {echo "SELECTED";} ?>><?php echo $row_category['cat_title']?></option>
<?php
} while ($row_category = mysql_fetch_assoc($category));
$rows = mysql_num_rows($category);
if($rows > 0) {
mysql_data_seek($category, 0);
$row_category = mysql_fetch_assoc($category);
}
?>
</select> </td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<a href="delete_citem.php?cat_id=<?php echo $row_category['id']; ?>&brand_id=<?php echo $row_brands['brand_id']; ?>">
select
</a></td>
</tr>
</table>

</form>
<p>&nbsp;</p>
</div>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($brands);

mysql_free_result($category);
?>
 
are you sure this line of code is right?
Code:
          <option value="<?php echo $row_category['id']?>"<?php if (!(strcmp($row_category['id'], $row_category['cat_id']))) {echo "SELECTED";} ?>><?php echo $row_category['cat_title']?></option>

it seems to say that if the two strings are NOT equal then assign them as selected. is not this inverted? if so, take out the exclamation mark (negation operator).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top