Page 1 of 1

Populating Individual Selected Boxes with MYSQL info

Posted: Sun Feb 15, 2004 1:31 pm
by polosport6699
Hey I have been trying to populate mysql boxes with info specific to each entry, for example if the customers $order_status = 4_1 I want the Varnished field to be selected, but when I run the query, I get a select box for each entry i have inserted in the database, displaying the correct values, but each entry in my database echos a new select box on each line, and I want just one, any help would be greatly appreciated.

The website that displays this problem is as follows:

http://www.pureimpressions.net/AMISH/ad ... sort=total

Code: Select all

<?php

<td bordercolor=7587AF bgcolor="$row_color" width=23%>";
					  
$query = "SELECT order_status, cust_name from customer_request ORDER BY cust_name ASC";
        						 $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());

### And print ###
while(list($order_status) = mysql_fetch_row($result))
						          {
if ($order_status == "4_1")
{
$status = "Staining";
} 
if ($order_status == "4_2")
	{
	$status = "Varnishing";
	} 
echo "<select name=selectbox>";
echo "<option value=$order_status selected=";
echo $status;
echo ">$status</option>";
echo "</select>";
}
echo "</td>";
?>

Posted: Sun Feb 15, 2004 1:36 pm
by vigge89
why do you echo $status as the value for selected?
also, all balues should have qoutes (double or single) around them...

Posted: Sun Feb 15, 2004 1:47 pm
by Dr Evil
Coud you explain a bit more precisely what you want ? I'm not sure I understand fully. But it looks very standard.

Posted: Sun Feb 15, 2004 1:48 pm
by JAM
Why not try to move the actual selectbox creation part of the script outside the while-loop?