Checking that a table exists on MySQL
Try this:
select case when (select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_NAME='offices') = 1 then 'exists' else 'does not exist' end
Try using the information_schema
to ask if the table exists. Something like
SELECT
*
FROM
information_schema
WHERE TABLE_NAME = "$table_array"
Take a look through everything the information_schema
holds, you will be pleasantly surprised by the information it has stored about your databases :)
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'"))==1)
echo "Table exists";
else echo "Table does not exist";
ref: check if MySQL table exists or not