I think this question is going to be rather interesting. So, as the title suggests, I am trying to make a dynamic select
field. Basically, when the time comes my web app will connect to my database, and pull the entire row that matches my query. My question is this: How can I present the data from ONE of the columns within the row as INDIVIDUAL options within the select
tag? This is what I am trying right now:
<select>
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "people";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
$search_query = "SELECT * FROM people_list WHERE person_id = $_SESSION[person_id]";
$result = $conn->query($search_query);
while($person_result_list = mysqli_fetch_assoc($result)){
echo "
<option value='$result[person_result_list]'>'$result[person_name]', '$result[person_result_list]'</option>
";
}
}
?>
</select>
This is returning an error:
Cannot use object of type mysqli_result as array
Which should be pretty straight forward to fix, but I just can't figure out the workaround to this. Any ideas?
Thanks all!