Skip to content

Instantly share code, notes, and snippets.

@kruxor
Last active August 29, 2015 13:58
Show Gist options
  • Save kruxor/10208209 to your computer and use it in GitHub Desktop.
Save kruxor/10208209 to your computer and use it in GitHub Desktop.
Will return true or false if a table exists or not $db is a mysqli db connection
<?php
function table_exists($table) {
global $db;
$sql = "SHOW TABLES LIKE '$table' ";
$result = $db->query($sql);
$num = 0;
$num = mysqli_num_rows($result);
if($num > 0) {
return true;
}
return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment