Form submission and MySQL retrieval

Discussion in 'PHP' started by Paxfia, Jan 7, 2010.

  1. Paxfia

    Paxfia New Member

    Joined:
    Dec 28, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.:eek:

    Help? Please and thank you :)
     
  2. gotroot

    gotroot New Member

    Joined:
    May 25, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    In my uncles garage (literally)
    whats the code?
    if u can post the mysql and php, i can probably help you
     
  3. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    yah displaying the code would help and meanwhile i think you tried using 'select from' and having some errors?
     
  4. johnny.dacu

    johnny.dacu New Member

    Joined:
    Jul 6, 2010
    Messages:
    88
    Likes Received:
    4
    Trophy Points:
    0
    in your action page perform a select query base on the provided id.
     
  5. raanrater

    raanrater New Member

    Joined:
    Aug 10, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.i-rater.com
    hi..

    can send me a code of forums in PHP...??? meet again.

    :baby:
     
  6. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    :S code of forums?
     
  7. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    You need to do

    PHP:
    $id$_POST['id'];
    if(
    is_numeric($id)) // check that its a real number
    {
    $q "SELECT * FROM table_name WHERE id=$id"//since its a number no need to add '".."'
    if(mysql_num_rows($q) < 1// check if theres any results returned
    {
    //trigger no results error
    echo " sorry but that id does not exist";
    }
    else
    {
    while(
    $get_all_info mysql_fetch_assoc($q))
    {
    $ID $get_all_info[id];
    $INFO $get_all_info[info];

    }
    }
    the $get_all_info is returned as an associative array with the columns of the table as the array index.
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice