Hello so i am trying to get the sum of a column in the mysql db is its 0 preform query 1 else query 2
Problem is it always goes to the first condition not the else even when value from mysql phpmyadmin shows 1 or 2 as if there is a problem in the if condition
<?php
$servername = "localhost:3306";
$username = "****";
$password = "*****";
$dbname = "****";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$search = $_GET['search'];
$sqlx = "SELECT SUM(`verified`) AS value_sum FROM Numbers WHERE `number` = ".$search." ";
$resultx = $conn->query($sqlx);
$sum = $row['value_sum'];
if ($sum == 0)
{
$sql = "SELECT * FROM `Numbers` WHERE (`number` LIKE '%".$search."%' or `name` LIKE '%".$search."%') and `blocked` = 0 and `verified` = 0 GROUP BY `name` Limit 20";
$result = $conn->query($sql);
}
else
{
$sql = "SELECT * FROM `Numbers` WHERE (`number` LIKE '%".$search."%' or `name` LIKE '%".$search."%') and `blocked` = 0 and `verified` = 1 GROUP BY `name` Limit 1";
$result = $conn->query($sql);
}