Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Form submission and MySQL query
01-07-2010, 09:53 PM #1
- Join Date
- Jan 2010
- Thanked 0 Times in 0 Posts
Form submission and MySQL query
I'm running on a limited knowledge of PHP, but I've been able to use intuition to get by up till now... I've got a problem, and I can't figure out the solution.
I managed to create a dynamic dropdown menu that populates itself with names from a MySQL table, with the option values being the IDs on the table. Using $_POST, the form sends the option value to another PHP page to execute the action.
I've confirmed that the action page IS receiving the proper ID number.
What I want to do is use PHP and the ID to retrieve the rest of the information relevant to that ID from the table and display it. (i.e., if I selected name#2, who's option value is 2, I want the action page to retrieve and display the rest of that entry (like phone number, email, etc.)
I have a feeling it's probably a fairly simple solution, I've just run out of ideas.
Help? Please and thank you
01-08-2010, 01:20 AM #2
- Join Date
- Dec 2009
- Thanked 58 Times in 58 Posts
You need to use some simple SQL to retrieve it, then fetch the value using the id. I'm not sure what your code is to retrieve it (if you're using a class or what to retrieve db info) but you should use the following sql query
SELECT * FROM table_name_here WHERE id = 'ID GOES HERE'
If you're just using basic mysql functions you can use
Of course, posting your code is always a good idea to help us help you!PHP Code:
$result = mysql_query("SELECT * FROM table_name_here WHERE id = '".mysql_real_escape_string($_POST['id'])."'");