Jump to content

How might I use dropdown lists, and update a database table?

Recommended Posts



I'd like to request a little guidance with regards forms and updating a database table please.


I've created a form which has a dropdown list.


I'd just like to enquire:-


1. How do I pass the selected result from the dropdown list to a variable? (at present I've written:- $user_gender = $_POST["profile_gender"] ;)


2. I'm unable to update the database table. The database opens and there's no errors reported. I'd just like to ask the following looks ok? $sql = "UPDATE registration_table SET Gender='$user_gender' WHERE Member_id='$userID'";


Thank You.


Share this post

Link to post
Share on other sites

Assuming the form was submitted properly, the value from the dropdown will be in one of the elements in $_POST or $_GET. You could assign it to a variable or use it directly.


You should use prepared statements for your queries. Here's the tutorial page for prepared statements:


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...