•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,799 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,353 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1371 | Replies: 2
![]() |
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:
[PHP]
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>";[/PHP]
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?
[PHP]
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>";[/PHP]
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!
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!
•
•
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation:
Rep Power: 5
Solved Threads: 20
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!))
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!))
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Expanding Box Problem (HTML and CSS)
- dropdown menu problem (HTML and CSS)
- Please anybody help to create autocomplete dropdown box with editable in asp.net (ASP.NET)
- PHP sessions/$_POST problem. Too Stressed today! (PHP)
- Dropdown box in Python (Python)
Other Threads in the PHP Forum
- Previous Thread: PHPbb - Dropdown menu Issue
- Next Thread: Encoder for PHP


Linear Mode