0

I am trying to select a table name from my MySql database, and write it out on my HTML page.

This is my query:

SELECT * FROM sted, attraksjon, reisetips

Then I am trying to write out the table names (sted, attraksjon and reisetips) in my HTML code. I tried this, but didnt work.

<?php while($rad = mysqli_fetch_array($datasett)) { ?>
    <li id="navigasjon"><a href="nettside.html"><?php echo $rad["sted"]; ?></a></li>
<?php } ?>

Someone help please

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

-1

try this

$table_query = 'SHOW TABLES in db_name';
$stmt = $conn->prepare($table_query);
$stmt->execute();
$table_num_result = $stmt->get_result();
while($rows = $table_num_result->fetch_assoc())
{
   $tables = $row['Tables_in_db_name'];

   echo $tables . '<br>';
}

this will list out all tables in your database, also replace db_name with your database name and $conn with your database connection variable.