this code will connect to a database and get you an array containing all the tables in that database:
$db = new mysqli('localhost', 'username', 'password', 'database_name');
if ($db->connect_error) {
die('Connect Error (' . $db->connect_errno . ') '
. $db->connect_error);
}
if (!$query = $db->query("SHOW TABLES")) {
die("query is false, query failed");
}
$tables = array();
while($row = $query->fetch_row()){
$tables[] = $row[0];
}
$db->close();
Once you you have your $tables array, you can check for the existence of a particular table like so:
if (in_array("some_table", $tables)) {
echo "table exists!";
} else {
echo "table does not exist";
}