I have checked everything on this topic, but nothing helped me to solve my problem. I'm very new to PHP, Jquery, MySql.
What I'm trying to achive is to auto populate a text field from a database table after chosing one item from a drop down list. The name of the database 'dependencies'. There is one table in it called 'categories' and it has 3 columns: id, name, description.
In the dropdown I want to by able to chose from this list in name, and then get description automatically into the text field. I achived to have the working dropdown, but I wasn't able to move on.

Here is my code so far:

```
<?php

 try {

$objDb = new PDO('mysql:host=localhost;dbname=dependencies', 'admin', 'admin');
$objDb->exec('SET CHARACTER SET utf8');

$sql = "SELECT * 
        FROM `categories`
        ";
$statement = $objDb->query($sql);
$list = $statement->fetchAll(PDO::FETCH_ASSOC);

} catch(PDOException $e) {
echo 'There was a problem';
}

?> 
<head>
     <script src="/js/jquery-1.6.4.min.js" type="text/javascript"></script>

     <script type="text/javascript">

     $(document).ready(function() 
       {      
         $("#dropdownid").change(function(){
             $('#textfieldid').val($("#dropdownid").val());
         });

      });
</script>
</head>
<body>

<label>List</label>
<select name="name" required id="dropdownid">
        <option value=""></option>
            <?php foreach($list as $row) { ?>
                    <option value="<?php echo $row['id']; ?>">
                    <?php echo $row['id']; ?> | <?php echo $row['name']; ?> | <?php echo $row['description']; ?>                        
                </option>
            <?php } ?>
</select>

<label>Text</label>
    <input name="description" type="text" id="textfieldid" value="">

</body>
</html>

```

I really appriciate any help.