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!

I hope you learned your lesson. Don't leave the quotes out of the HTML, they're important!

I learned that lesson about 6 months ago myself. Somewhere between blog software version 0.3 and 0.4. (http://www.puckdroppers.us/blog/ (plug!))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.