Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Question Unanswered: Populating form from database using a dynamic dropdown list.

    Hello, I need to populate a form with an address using a dropdown list to select the address. The address details is taken from a database.The dropdown list is dynamicaly created from the same database.

    I can populate the dropdown list fine, I just need to be able to set the rest of the form. I'm using a MySQL database and PHP4 to interact with it.

    This is the code so far.
    PHP Code:
    <?

    mysql_connect
    ("localhost","root");
    mysql_select_db("Droppop");
    $sql "SELECT * FROM address";
    $result mysql_query($sql);
    while(
    $row=mysql_fetch_array($result)){
        
    $option .= "<option value=".$row[id].">".$row[name]."</option>";
    }

    ?>
    HTML Code:
    <form>
    <select name="name" id="name" onChange="this.refresh">
    <option></option>
    <?=$option?>
    </select><br />
    PHP Code:
    <?

    $sql 
    "SELECT * FROM address WHERE id = $name";
    $result mysql_query($sql);
    while(
    $row=mysql_fetch_array($result)){
        
    $address1 $row[address_1];
        
    $address2 $row[address_2];
    }

    ?>
    HTML Code:
    <input type="text" name="address_1" value="<?=$address1?>" disabled><br />
    <input type="text" name="address_2" value="<?=$address2?>" disabled>
    </form>
    Thanks in advance for your help.
    Nalum

  2. #2
    Join Date
    Jul 2004
    Posts
    62
    This java forums , yet you may try in PHP forum

    Seems that everything is ok, what is the problem

Posting Permissions

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