Check if MySQL Table Exists
Jan 27, 2009 · 1 minute readCategory: php
This is post is now quite old and the the information it contains may be out of date or innacurate.
If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub
function db_table_exists($table){
$exists = false;
$tables_query = db_query("SHOW TABLES FROM " . MYSQL_DB);
while($t = mysql_fetch_assoc($tables_query)){
foreach($t as $k=>$v){
if($v == $table){
$exists = true;
break;
}
}
}
return $exists;
}