This is a two part Question - sorry!
I see there are lots of answers to the first part, I.E. How to populate a Drop Down List in a Form.
PART 1 However, when I place the Form (with the DDL) in a Table it all goes wrong and doesn't work.
Question 1 Why isn't the DDL populating? - There are 4 names in the table each with various other columns - ID, Name, Nickname etc.
Part 2 I want to return the 'ID' of the selected 'Name', which I then will add to another table with other data in it. At the moment the 'ID" is not being passed to the PHP that is writing to the file.
Question 2 What do I need to add to my code to return the ID of the selected Name? I.E. I don't want the Name in the table, just the ID of the Name.
Code is here:
<!doctype html>
<html>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
// Create connection
$conn = mysqli_connect( $servername, $username, $password, $dbname );
// Check connection
if ( $conn->connect_error ) {
  die( "Connection failed: " . $conn->connect_error );
}
?>
<body>    
<form method="post" action="property.php">
  <table>
    <tr>
      <td>Property Name:</td>
      <td><input type="text" name="name"></td>
  </tr>
    <tr>
      <td>Agent Name:</td>
      <td>
          <select>
            <?php
            $res = mysqli_query( $conn, "select * from Names" );
            while ( $row = mysqli_fetch_array( $res ) ) {
              ?>
            <option value="id">
            <?php echo $row["name"] ?>
            </option>
            <?php
            }
            ?>
            </select>
      </td>
    </tr>
  </table>
</body>
</html>
Any help would be awesome!!
Cheers!!
 
    