Select option not working
Posted: Mon Jul 12, 2004 3:01 pm
I have used this code before and need to use it again. Why does the first one work and not the second one? I have pored over this for a couple of hours and can't find the difference.
I know that the database and field names are right because the first item in the second code comes up - it's just that the whole list (in this case of order numbers) won't appear. I would appreciate any help.
This works:
This doesn't:
I know that the database and field names are right because the first item in the second code comes up - it's just that the whole list (in this case of order numbers) won't appear. I would appreciate any help.
This works:
Code: Select all
<?php
foreach ($_GET as $key => $value) {
$_GET[$key] = trim($value);
}
mysql_select_db($database_hschamber, $hschamber);
$query_rsCategories = "SELECT * FROM Category1 ORDER BY cat_desc1";
$rsCategories = mysql_query($query_rsCategories, $hschamber) or die(mysql_error());
$row_rsCategories = mysql_fetch_assoc($rsCategories);
$totalRows_rsCategories = mysql_num_rows($rsCategories);
?>
<select name="searchCategory">
<?php
do {
?>
<option value="<?php echo $row_rsCategories['cat_id1']?>"><?php echo $row_rsCategories['cat_desc1']?></option>
<?php
} while ($row_rsCategories = mysql_fetch_assoc($rsCategories));
$rows = mysql_num_rows($rsCategories);
if($rows > 0) {
mysql_data_seek($rsCategories, 0);
$row_rsCategories = mysql_fetch_assoc($rsCategories);
}
?>
</select>Code: Select all
<?php
foreach ($_GET as $key => $value) {
$_GET[$key] = trim($value);
}
mysql_select_db($database_mfm, $mfm);
$query_rsOrders = "SELECT * FROM orders ORDER BY order_no";
$rsOrders = mysql_query($query_rsOrders, $mfm) or die(mysql_error());
$row_rsOrders = mysql_fetch_assoc($rsOrders);
$totalRows_rsOrders = mysql_num_rows($rsOrders);
?>
<select name="selectOrders">
<?php
do {
?>
<option value="<?php echo $row_rsOrders['order_no']?>"><?php echo $row_rsOrders['order_no']?></option>
<?php
} while ($row_rsOrders = mysql_fetch_assoc($row_rsOrders));
$rows = mysql_num_rows($rsOrders);
if($rows > 0) {
mysql_data_seek($rsOrders, 0);
$row_rsOrders = mysql_fetch_assoc($rsOrders);
}
?>
</select>