User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

php dropdown box problem

  #1  
Sep 18th, 2006
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 228
Reputation: nathanpacker is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nathanpacker's Avatar
nathanpacker nathanpacker is offline Offline
Posting Whiz in Training

Re: php dropdown box problem

  #2  
Sep 18th, 2006
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!
Reply With Quote  
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation: Puckdropper is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 20
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: php dropdown box problem

  #3  
Sep 20th, 2006
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!))
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC