> while ($row = mysql_fetch_array($sql_result)) {
> echo"<tr><td>";
> echo $row["paint"];
> echo"</td><td>";
> echo $row["bucket"];
> echo"</td><td>";
> echo"<form action=\"http://www.\" method=\"POST\">";
> $Color = $row["Color"];
> if ($Color == $Color) {
Here is one problem: You can't use $Color for the current color you are
printing *AND* the color they previously selected.
$Color == $Color will *always* turn out to be TRUE. It's a "truism", like
asking if ("Blue" == "Blue")
You need a separate variable name for the selected color, like,
$SelectedColor, or you could use $Col for the $row["Color"], but you can't
use $Color for both the selected color and the current possible option.
> $option .= "<OPTION value=\"$Color\" selected>$Color</OPTION>";
> } else {
> $option .= "<OPTION value=\"$Color\">$Color</OPTION>";
> }
> echo"<select name=\"Colors\">";
> echo "$option";
> echo"</select>";
>
> as you can see I end up with a select menu with this "green, blue, red"
> as the only option.
>
> is there a way I can tell php3 to break it down at "," so I can actually
> have a drop down menu
Something like this inside your loop might be what you want:
$Colors = $row["Color"];
$options = explode(",", $Colors);
while (list(,$Color) = each($options)){
$option .= "<OPTION>$Color</OPTION>\n";
}
I'm not real sure that you should have Red, Green, Blue in your database in
the first place though...
It's usually a better idea to store this as a "relation":
Colors:
ColorID Color
---------------
1 Red
2 Green
3 Yellow
4 Blue
Buckets:
BucketID Paint Bucket Weight
----------------------
1 Good Good 100kg
2 Okay Good 120kg
BucketColors
--------------
BucketID ColorID
1 1
1 2
1 4
2 1
2 3
This last table says, that bucket # 1 is "related to" Color 1 (Red), Color 2
(Green) and Color 4 (Blue)
Bucket #2, on the other hand, is "related to" Color 1 (Red) and Color 3
(Yellow)
But, if all you are doing is saying that the only choices for a Bucket ever
are Red/Green/Blue, ignore all that... :-)
--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]