Depending on whether any results are found or not I want to set a value to $case_num and store it in an array to pass back to an AJAX call using json. The code I am using works as expected if an entry is found but if there are no results the value passed back is simply null.
$sql = "SELECT * FROM cases WHERE name LIKE '%$serial%'
AND DATE(date_entered) = CURDATE()";
$result_case = mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli));
$row = mysqli_fetch_array($result_case);
if(!empty($result_case)){
$case_id = $row['id'];
$case_num = $row['name'];
}else{
$case_num = 'not found';
}
$output_array = array(
'source' => $source,
'case_found' => $case_num
);
echo json_encode($output_array);
$result_casewill never be empty, NEVER.