Skip to content
Advertisement

How to Check if value exists in a MySQL database

Suppose I have this table:

JavaScript

I want to check if the value c7 exists under the variable city or not.

If it does, I will do something.
If it doesn’t, I will do something else.

Advertisement

Answer

preferred way, using MySQLi extension (supported from PHP 5 onwards):

JavaScript

deprecated and not supported in PHP 7 or newer:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement