I want to pick up peoples names from a phpmyadmin database and place them in a HTML select box, when the user picks a name from the select box it should display the detail from the database for that person in a table. I can't seem to get this to work, I can get the names to pick up from the database and display in a select box but when you click on the name it seems to bring up every record in the database rather than just the one for that person. I am using mysql rather than mysql. Here is my code
This is my back end stuff
<?php
$conn = mysqli_connect("localhost", "root", "root") or die ("No connection");
mysqli_select_db($conn, "flat") or die("db will not open");
$query = "select FlatCode, Address from FLAT";
$result = mysqli_query($conn, $query) or die("Invalid query");
echo "<table border='1'><tr><th>modulecode</th><th>studentnum</th></tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td></tr>";
}
echo "</table>";
mysqli_close($conn);
?>
this is my front end stuff
<font size="4"> Choose an Owner Name</font><br><br>
<form action="flat.php" method="post">
<select name="name">
<?php
$con = mysqli_connect("localhost", "root", "root") or die ("No connection");
mysqli_select_db($con , "flat") or die ("db will not open");
$query = "SELECT distinct OwnerName, FlatCode, Address from FLAT";
/*$query= $_POST ("name")
function change_guery($query)
mysqli_use_result*/
$result = mysqli_query($con, $query) or die("Invalid query");
while($rows = mysqli_fetch_array($result))
{
echo "<option value=\"" . $rows[0] . "\">" . $rows[0] . "</option>";
}
echo "</select>";
mysqli_close($con);
?>
<input type="submit" value="Submit Value">
</form></body></html>
</div>