Hey everyone. Got a little problem with an html dropdown box I'm using in a php document. Here's the code I'm using:

echo    "<td width=52% bgcolor=cdcdcd><form method=post action=myphpdocument.php>";
$query = mysql_query("SELECT clientname FROM clients");
echo "<select name=client>";

while ($r = mysql_fetch_array($query))
{
$client = $r["clientname"];
echo "<option value=$client>$client</option>";
}
echo"</select>";

The dropdown box populates with all the fields properly from the database, but when you submit the form, it only sends the first word of the choice you've chosen in the box. So for example if the choices in the dropdown box were:

Mellow Yellow
Dr. Pepper
Diet Pepsi

Then if you select "Mellow Yellow", the form would only send the word "Mellow", or "Dr." or "Diet" and so forth. How can I get it to submit the entire line?

Hey, just thought I'd let you all know I solved the problem. I knew there needed to be quotes around the "$client" in <option value=$client>, but the quotes in the php were screwing it up, so I had taken them all out. Well that's all I needed to do was put the quotes back in, but slash them out. So I ended up with <option value=\"$client\">.

Works like a charm now. I always do this. I worked for an hour and half trying to figure out this problem. Then I post a quesiton on here, and 5 mintes later, I solve it on my own. Lame. Thanks anyway!

This article has been dead for over six months. Start a new discussion instead.