...

View Full Version : Form submission and MySQL query



Paxfia
01-07-2010, 10:53 PM
Hi all,

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

Help? Please and thank you :)

JAY6390
01-08-2010, 02:20 AM
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

$result = mysql_query("SELECT * FROM table_name_here WHERE id = '".mysql_real_escape_string($_POST['id'])."'");
Of course, posting your code is always a good idea to help us help you! ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum