Name

mysql_list_tables

Synopsis

qresource mysql_list_tables(string database[, cresource connection])

Returns a query resource handle that can be used to retrieve information about the tables within the given database. The table name information can be retrieved with the function mysql_tablename( ). An optional connection resource handle may be provided as the second parameter; otherwise, the most recently opened connection that is still open is assumed.

Returns false on failure.

Example

<?php
  $connection = mysql_connect("localhost", "fred", "shhh");
  
  $result = mysql_list_tables("wedding", $connection);
  
  echo "The tables of wedding are: ";           
  for($x=0; $x < mysql_num_rows($result); $x++)
     echo mysql_tablename($result, $x) . " ";
?>

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.