Quick disclaimer- This is a homework assignment and I've gone through my notes and book and several online examples but I'm not getting anywhere.
I have database that I need to move into a PHP page. The PHP page will have a drop down list populated by a MySQL query, when the user clicks on a choice the page should return to itself another MySQL query. So when I chose a name, the flight information about that Name should be returned. I know I have to do something with $_POST but as having 3 days experience with PHP I'm not really sure how this will work.
<?php
try
{ //database login
$dsn="mysql:host=courses; dbname=z1756942";
$pdo = new PDO($dsn, $user, $password);
//sql command to populate drop down list
$sql = ("SELECT CONCAT(fname,' ', lname) as full_name FROM passenger;");
//sql statement to return on drop down pick
$r->full_name;
$row=$pdo->query($sql);
?>
<!-- start the drop down box -->
<form action=" " method ="POST">
Passenger by Name:
<select id="name" name="name">
<option value= 0>Choose</option>
<?php
//populate the drop down box
foreach($row as $r)
{
$name=$r['full_name'];
echo "<option value=\"$name\">".$name.'</option>';
}
?>
</select>
<input type="submit" value="Submit">
</form>
<?php
I have the tags for HTML, body and my catch statement, those all work correctly. The MySQL statement that needs to be returned to the same page is
SELECT flightnum, dateofflight, seatnum FROM manifest, passenger WHERE manifest.passnum LIKE passenger.passnum;