I have a PHP script that creates a new table in a database which pre-establishes the fields: id, firstName, lastName, and some others. The table name is determined from $_GET's of firstName and lastName from the URL.
So, url.com/script.php?fn=Bob&ln=Smith
yields the table name BobSmith.
When the script that creates the table is submitted, the page refreshes and values can be inserted into the table using another script.
What I'm trying to do is create a separate page that displays all of the tables while echoing the values from the firstName and lastName fields, limited to 1 result, as all of the rows in the table will have the same firstName and lastName.
So what I'm looking for is a way of showing the results from the SHOW TABLES query, but using data from each respective table.
Example:
<?php
$query1 = mysql_query("SHOW TABLES");
$result1 = mysql_list_tables("customers")
$num_rows = mysql_num_rows($result1);
for ($i = 0; $i < $num_rows; $i) {
$table_name = mysql_tablename($result1, $i);
}
$query2 = "SELECT * FROM $table_name";
$result2 = mysql_query($query2);
while($row = mysql_fetch_object($result2)) { ?>
<a href="script.php?fn=<?php echo $row->firstName; ?>&ln=<?php echo $rowLastName; ?>"><?php echo $row->firstName; ?> <?php echo $row->LastName; ?></a>
<?php } ?>
I know that's not really functional code. I'm just not sure how to put it all together or if I'm even approaching this the right way.