Answers for "How to Check if value exists in a MySQL database if statement php"

PHP
2

check if table exists sql php

if ($result = $mysqli->query("SHOW TABLES LIKE '".$table."'")) {
    if($result->num_rows == 1) {
        echo "Table exists";
    }
}
else {
    echo "Table does not exist";
}
Posted by: Guest on December-08-2020
0

php mysql if exists

$mysqli = new mysqli(SERVER, DBUSER, DBPASS, DATABASE);
$result = $mysqli->query("SELECT id FROM mytable WHERE city = 'c7'");
if($result->num_rows == 0) {
     // row not found, do stuff...
} else {
    // do other stuff...
}
$mysqli->close();
Posted by: Guest on January-16-2021

Code answers related to "How to Check if value exists in a MySQL database if statement php"

Browse Popular Code Answers by Language