PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in
<?php
include("header.php");
$_SESSION['loc'] = "viewkeyowners.php";
if ($_SESSION['loggedin'] <> 1)
{
header("Location: logintest.php");
exit();
}
//this is done because if user closes a tab/page, and logs back in(still in session), it would redirect to the last opened tab/page
function onclose(){
unset($_SESSION['loc']);
}
register_shutdown_function('onclose');
if(isset($_SESSION['illegalmove'])){
if($_SESSION['illegalmove'] == 1){
echo "<script>alert('Your account is not authorized to view this page.');</script>";
$_SESSION['illegalmove'] = 0;
}
}
if(isset($_POST['checking_viewbtn']))
{
$id = $_POST['id'];
// echo $return = $id;
$query = "SELECT * FROM keyOwners WHERE id='$id' ";
$query_run = mysqli_query($conn, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $row)
{
echo $return = '
<h5> Key Type : '.$row['keyType'].'</h5>
<h5> Key Department : '.$row['area'].'</h5>
<h5> Key Description : '.$row['keyDesc'].'</h5>
<h5> Key Status : '.$row['keyStatus'].'</h5>
<h5> First Name : '.$row['fname'].'</h5>
<h5> Last Name : '.$row['lname'].'</h5>
<h5> Employee Status : '.$row['emplStatus'].'</h5>
<h5> Employee Number : '.$row['emplNum'].'</h5>
<h5> Date Assigned : '.$row['dateAssigned'].'</h5>
<h5> Updated By : '.$row['userid'].'</h5>
';
}
}
else
{
echo $return = "<h5>No Record Found</h5>";
}
}
?>