I\'m trying to check if a file name already exists in the \"reviews\" column within a particular category, before it\'s created. If it already exists, I want to add today\'s dat
When you use COUNT()
in your query you will always get one row returned even if only to tell you the count is zero. You need to check the value of COUNT(reviews)
to get that value:
$result = mysqli_query($sqli, "SELECT count(reviews) AS `count` FROM myTable WHERE `category`='$list' AND `reviews`='$php_file_name'");
$check = mysqli_fetch_assoc($result);
if($check['count'] >= 1){
You'll notice that I gave count(reviews)
an alias as it makes accessing that value easier in the PHP code.