I know that this question has been on multiple S.O. forums, but after reviewing, I seem to not be able to get the data elements in my phpmyadmin to appear in my html select. I am new to php, so therefore I am not very good at the fundamentals. Can anyone take a look at my code and tell me whats wrong with it? I am not getting any errors, just nothing in my html select.
Code:
<?php
$con = mysqli_connect('localhost','root','','Lab2_Database');
if($con-> connect_error) {
die("Connection Failed:".$con-> connect_error);
}
?>
<h1 id="header">Welcome to The Flight Club WebSite</h1>
<br>
<p>Select a Flight by Flight Number:</p>
<form>
<select>
<option value="0">Flight Number</option>
<?php
$sql = "SELECT flightNumber FROM Flight";
$result = $con-> query($sql);
while($row = mysql_fetch_assoc($get))
{
?>
<option value = "<?php echo($row['flightNumber'])?>" >
<?php echo($row['flightNumber']) ?>
</option>
<?php
}
?>
</select>
</form>
</body>
</html>
$result = $con-> query($sql);
while($row = mysql_fetch_assoc($get))
{
?>
<option value = "<?php echo($row['flightNumber'])?>" >
<?php echo($row['flightNumber']) ?>
</option>
<?php
}
change with
$result = $con-> query($sql);
while($row = mysql_fetch_assoc($result))
{
?>
<option value = "<?php echo($row['flightNumber'])?>" >
<?php echo($row['flightNumber']) ?>
</option>
<?php
}
variable $get is not defined i think
you are using mysql with mysqli object
$result = $con-> query($sql);
while($row = mysql_fetch_assoc($get))
{
?>
change this to
$result = $con-> query($sql);
while($row = $result->fetch_assoc())
{
?>