Hello i am able to use a drop down list to show rows from a table but what i am wanting to is to populate the drop down list with the 2 tables i have in my database.
Example: i am currently listing members from the table members
bob jake chris
but what i am wanting to do is to list the tables
members cars
<?php
// check for errors
ini_set('display_errors', 1);
//calls connection
require_once('connection.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<h1> View Table(s) </h1>
<?php
// calls get results method to list members
$ResultSet = getResults("members");
echo "<table border='1' cellpadding='6'>";
echo "<tr> <th>Id</th> <th>First Name</th> <th>Second Name</th> <th>Age</th> <th>Email</th>";
foreach ($ResultSet as $row) {
echo "<tr>";
echo "<td>" . $row ['id'] . "</td>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['second_name'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
echo "<table>";
?>
<br/>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'>
<p>Choose a member to view:</p>
<select name='members' id="ddmembers">
<?php
$results = getResults('members');
if ($results) {
foreach ($results as $row) {
echo '<option value="' . $row['id'] . '">' . $row['first_name'] . '</option>';
}
}
else
echo '<option value="0"0"> No Data</option>';
?>
</select>
<input type="submit" id="submit" value="Submit"/>
<br/>
<br/>
</form>
<?php
//Message for what has been selected
if (isset($_POST['members'])) {
echo 'You have selected Member ' . $_POST['members'];
}
?>
</body>
</html>