H
H
heatshot132018-07-15 15:33:43
PHP
heatshot13, 2018-07-15 15:33:43

How to check if there is a record in the database or not?

Security Code

$today = date("Y-m-d"); // менял на дату $today = '2018-07-15' тоже не находит 
$query = mysql_query("SELECT * FROM `EveryDayVisit` WHERE `data` = '$today'");
if(mysql_num_rows($query) > 0)
{
echo 'Зап. есть';
}
else
{
echo 'Не найден в базе данных';
}

Records by date are in the database and on the output
echo 'Не найден в базе данных';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Novikov, 2018-07-15
@paulfcdd

mysql_query has long been depricated in PHP, there is PDO to work with the database. Are you sure that, for example, the date is in the format in which you send it in the request? Or that the table is definitely not empty?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question