Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php mysql if not exists insert

$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();
 
PREVIOUS NEXT
Tagged: #php #mysql #exists #insert
ADD COMMENT
Topic
Name
8+6 =