Results 1 to 1 of 1

Thread: populate php form with mysql after selecting drop down

  1. #1
    Join Date
    Feb 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post populate php form with mysql after selecting drop down

    Hello.

    New to the forum and new to PHP. Working hard to learn all I can, but at the moment, I appear to be completely lost.

    I am trying to create a form for coaching my team, and I have it the drop down working so it pulls my team name from a MYSQL database, now I am trying to have it so, depending on which team member I select, it will populate other data from the database. Such as employee number, birth date, contact information.

    Every time I think I have it working, I fail miserably.

    Currently, this is the script I am using, but am failing at trying to get it to work correctly.

    PHP Code:
    <?PHP

    $db_host
    ="localhost";
    $db_user="root";
    $db_password="test";
    $db_name="master";

    $cn=mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
    mysql_select_db($db_name,$cn) or die(mysql_error());
    $sql "SELECT fullname, id, birthday FROM employees";
    $rs mysql_query($sql) or die(mysql_error());
    echo 
    "<select>";
    while(
    $row mysql_fetch_array($rs)){
    echo 
    "<option value='".$row["fullname"]."'>".$row["fullname"]."</option>";
    echo 
    "</select>";
    echo 
    "<br />";
    echo 
    "<tr>";
            echo 
    "<td>Nordia ID:"$row['id']. "</td>";
            echo 
    "<br />";
            echo 
    "<td>Supervisor:"$row['birthday']. "</td>";
            echo 
    "<br />";
    echo 
    "</tr>";
    }
    mysql_free_result($rs);
    Presently, if i remove the echo "</select>"; it will only display the drop down with the MYSQL populated list. If I leave it in, if fills all of the page with all of the data I requested, simply, without the drop-down choice.

    Please help guide this stray dog down the right path.

    Thanks in advance.
    Last edited by jscheuer1; 02-16-2015 at 05:05 PM. Reason: format code

Similar Threads

  1. Replies: 9
    Last Post: 08-26-2015, 06:16 PM
  2. How to populate php/html form with MySQL data
    By peterv in forum MySQL and other databases
    Replies: 1
    Last Post: 06-13-2009, 09:18 PM
  3. Selecting a point on a Google Map with a drop down form
    By myscranton in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-13-2009, 03:05 AM
  4. Populate form form MySQL data
    By Rob (SA) in forum MySQL and other databases
    Replies: 13
    Last Post: 04-18-2009, 10:48 AM
  5. Populate a Text field via MYSQL Drop Down
    By xChAMaRx in forum JavaScript
    Replies: 0
    Last Post: 02-16-2009, 12:04 PM

Bookmarks

Posting Permissions

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