update' select menu

Reply

Join Date: Nov 2007
Posts: 53
Reputation: dottomm is an unknown quantity at this point 
Solved Threads: 0
dottomm dottomm is offline Offline
Junior Poster in Training

update' select menu

 
0
  #1
Apr 2nd, 2008
Thank you in advance to anyone who can solve this for me.

In a registration form of mine the user selects the state they live in with a drop down menu.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: update' select menu

 
0
  #2
Apr 2nd, 2008
And what do you want to update ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 53
Reputation: dottomm is an unknown quantity at this point 
Solved Threads: 0
dottomm dottomm is offline Offline
Junior Poster in Training

Re: update' select menu

 
0
  #3
Apr 2nd, 2008
I'm sorry. I using php to update a mysql db.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: update' select menu

 
0
  #4
Apr 2nd, 2008
You have a name for the dropdown list. Right ? When you submit the form, you get the value of the dropdown list by doing $value = $_POST['dropdownlistname']. Insert/update that value to the table.
You can see here how you can connect, insert or update mysql tables using php.
http://www.w3schools.com/php/php_mysql_intro.asp
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 53
Reputation: dottomm is an unknown quantity at this point 
Solved Threads: 0
dottomm dottomm is offline Offline
Junior Poster in Training

Re: update' select menu

 
0
  #5
Apr 2nd, 2008
First, let me say thank you for such rapid responses.

I apologize. I'm probably not explaining myself correctly.

I do not have any trouble updating the record with the select menu, what I can't make work is getting the select menu to be 'display' or be 'pre-selected' based on the users input that already lives on the db.
What happens is - when a users chooses to update their record, update.php is a form with all of their fields displayed 'pre-populated' - all but the drop-down menus. I keep getting value =0.

Thanks again.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: update' select menu

 
0
  #6
Apr 2nd, 2008
Okay! I saw your other thread. Anyways, this is how you can make it work. Have an onchange event in your selectbox. When a value is selected, submit the page. (document.form.submit()). $_POST['selectboxname'] will have the value selected from the dropdown. Then check if it matches with each option value. If it matches, then echo "selected", or else, echo nothing.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 53
Reputation: dottomm is an unknown quantity at this point 
Solved Threads: 0
dottomm dottomm is offline Offline
Junior Poster in Training

Re: update' select menu

 
0
  #7
Apr 2nd, 2008
Again, Thank you.

I'm afraid I understand a little of what you are suggesting to do.

I do not want the form to submit on change.
Can you explainhow to "Check if it matches". I'm doing U.S states (all 50). Would I have to do if /else statements for each?

I hope I am making clear what I am trying to do.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: update' select menu

 
0
  #8
Apr 2nd, 2008
Okay. Can you post your code ? I need to see why your page showing the 'default value' instead of the selected value ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC