I wasn't sure if I should be posting in the newbie forum or here, so I'll try here in hopes that someone can help me out.
I have 2 tables. 3 of the columns have the same rows (id, lastname1, firstname1) all the rest of the columns are different.
I want to display both tables together in one html table.
I can display the results from one table by doing this
<?php
// connect to the database
include('connect-db.php');
// get results from database
$result = mysql_query("SELECT * FROM users ")
or die(mysql_error());
// display data in table
echo "<table border='1' cellpadding='10'>";
echo "<tr><th colspan=6>Membership Database</th></tr>";
echo "<tr> <th>ID</th> <th>Last Name</th> <th>First Name</th> <th>New Member</th> <th>Returning Member</th><th></th> <th></th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['lastname1'] . '</td>';
echo '<td>' . $row['firstname1'] . '</td>';
echo '<td>' . $row['NewMember'] . '</td>';
echo '<td>' . $row['ReturningMember'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit/View</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
But I don't know how to include the 2nd table into the fray of things. I've tried
$result = mysql_query("SELECT * FROM users, youth ")
But that didn't work. It just displays the data from the youth's table if I do that, and it displays it 9 times even though I only have 4 records in the youth table.
Oh and of course the edit and delete links would need to change according to which table it's pulling it from.
Can anyone shed some light?