This little function checks if $table exists in $db.

If it does it will return true, if it does not, it will return false.


You will need to have opened a connection to the MySQL server before using it.
<?php
<?

function
table_exists($table,$db) {
$tables = mysql_list_tables($db);
while (list(
$temp) = mysql_fetch_array($tables)) {
if(
$temp == $table) {
return
TRUE;
}
}
return
FALSE;
}


/** How to use it **/
if (table_exists(test_table, my_database)) {
echo
"Yes the table is there.";
}

?>
?>