I'm sure someone on here can help me. I'm pretty new to PHP (been learning for a couple of weeks) and am trying to populate ONE drop down box with info from a MYSQL database.
The problem is that instead of all information going into one drop down box, each row of information is displayed in its own drop down box! I feel all I need is like a small change to my code, but haven't got a clue what to do.
I have also attached a screenshot.
Someone please help me!
<?php
require_once ('mysqli_connect.php'); // ACTUAL QUERY
$q = "SELECT CONCAT(route) as flight FROM flight_details";
$r = @mysqli_query ($dbc, $q);
if ($r) {
echo '<table align="left" cellspacing="3" cellpadding="3">
<tr><td><b>Flights:</b></td></tr>'; // TABLE HEADER
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { // HERE THE ROUTES ARE PRINTED
echo '<tr><td align="left"><select name="flight"><option>' .
$row['flight'] .'</option></select></td></tr>';
}
echo '</table>';
mysqli_free_result ($r);
} else { // ROUTES CANNOT BE RETRIEVED
echo '<p class="error"> Flight details could not be retrieved. Please try again later.</p>';
echo '<p>' . mysqli_error($dbc) .
'<br /><br />Query: ' . $q .
'</p>';
}
mysqli_close($dbc);
?>