Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form submission and MySQL query

    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.

    Help? Please and thank you

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    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
    PHP Code:
    $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!
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •