You need to choose a single style for storing numbers, so that you can further bring the number to the same type and look in the database.
For example, you can at least remove all that are not numbers:
$phone_number = preg_replace('/[^0-9]/', '', $phone_number); //save phone
When searching in the same way, delete all that is not numbers from the string and search in the database:
$phone_client = preg_replace('/[^0-9]/', '', $phone_client); //Выбираем только одну запись $sql = "SELECT * FROM `lids` WHERE id_cabinet = :room AND tel = :phone LIMIT 1"; $pdo->prepare($sql); $pdo->execute([':room'=>$id_cabinet, ':phone'=>$phone_client]); if(($result = $pdo->fetch()){ print_r($result); };
mysql - This extension has been deprecated since PHP 5.5.0, and has been removed from release 7.0.0. Use mysqli or PDO
The principle is how to store user passwords, when you save, encode, when searching, encode the received password and compare it with what is in the database.
If you can receive different formats, for example, you have saved with a country code, or a number without a code can come in, you can simply search by the occurrence of a string ( sql_like ).
You can try to use the library libphonenumber , with its help you can get information about the number, check for validity, choose one of the formats.