MYSQL_LIST_TABLES( )

Author Topic: MYSQL_LIST_TABLES( )  (Read 452 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 159
  • Karma: 0
    • Hot Shaper
MYSQL_LIST_TABLES( )
« on: 05-25-2016, 03:22:00 »
If given a database name this function will return a result identifier to a list of tables within a database


Quote
int mysql_list_tables (string database [, int link_identifier])


Like mysql_query(),  this  function  doesn’t  contain  the  results;  those  must  be fetched  with  the  mysql_tablename() function.  The  following  example  shows  how you might use these functions to get a listing of tables from the database named “test”


Quote
$tables=mysql_list_tables(“test”);
for($i=0; $i<mysql_num_rows($tables); $i++)
{
echo mysql_tablename($tables,$i), “<br>\n”;
}

If you don’t wish to commit these functions to memory, you could use the following code to achieve the same thing.


Quote
$result = mysql_query (“show tables from test”) or
die( mysql_error() );
while( $row = mysql_fetch_row($result) )
{
echo $row[0], “<br>\n”;
}