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.

Recommended Answers

All 7 Replies

And what do you want to update ?

I'm sorry. I using php to update a mysql db.

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. 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

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.

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 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.

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.

Okay. Can you post your code ? I need to see why your page showing the 'default value' instead of the selected value ?

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.