Hi folks,
I am trying to select the option of a drop down list, if the variable appears ina nother query, however, I can't get the if statment to work.
$myrow['catID'] = $myrow['productcat'] doesnt seem to work.
Can anyone please help?
Thankyou
<h2>Product Detail</h2>
<?php
//populate fields
$link_id = db_connect();
$query = "SELECT * FROM products WHERE productid = $productid";
$result = mysql_query($query);
if ($myrow = mysql_fetch_array($result)) {
?>
<form name='send' method='post' action=''>
<input name='productid' type='hidden' value="<?php echo $productid; ?>">
<table width='100%' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='21%'><strong>Product Name</strong></td>
<td width='79%'><input type='text' name='productname' value="<?php echo $myrow['productName']; ?>"></td>
</tr>
<tr>
<td><strong>Product Description</strong></td>
<td><input type='text' name='productdescription' value="<?php echo $myrow['productDescription']; ?>"></td>
</tr>
<?php } ?>
<tr>
<td><strong>Category </strong></td>
<td colspan='3'><select name='productcategory'>
<option value=''>---------------------- </option>
<?php
$link_id = db_connect();
$query = 'SELECT * FROM productCat';
$result = mysql_query($query);
while ($myrow = mysql_fetch_array($result)) {
?>
<option value="<?php echo $myrow['catID']; ?>"
<?php
If ($myrow['catID'] = $myrow['productcat']) {
echo "selected='selected'";
}
?>
> <?php echo $myrow['CatName']; ?></option>
<?php } ?>
</select>
</td>
</tr>
</table>
<input name="edit" type="submit" value="edit">
</form>