Name

mysql_tablename

Synopsis

string mysql_tablename(qresource query, int table[, mixed unused])

Returns the name of a table from a prior query with mysql_list_tables( ). The second argument is an ordinal table index into the query result set, where the first table in the result set is numbered zero. The number of table names in the result set can be determined using mysql_num_rows( ).

This function returns false on error. A common source of error is supplying a table number that is greater than the number of tables available in the database.

Tip

This function is an alias to mysql_result( ). It is therefore possible to supply a third argument to this function, but it should not be used in practice with mysql_tablename( ).

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.