Good day!
I am having trouble displaying a "No records found" message in my PHP process.
Here is the code for my search query:
if(isset($_GET['submit'])) {
$product = $_GET['product'];
$city = $_GET['city'];
$query = "SELECT * FROM $product WHERE city = '$city'";
$result = mysqli_query($con, $query) or die ("Could not connect to database.");
$product = str_replace('_', ' ', $product);
$product = strtoupper($product);
echo "You have searched for " . $product . " in " . $city;
echo "<table border=1>";
echo "<tr> <th>Store</th> <th>City</th> </tr>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr><td>";
echo $row['store'];
echo "</td><td>";
echo $row['city'];
echo "</td></tr>";
}
echo "</table>";
}
My problem is I don't know where and what to place the conditional statement that will show "No records found".
Hoping that someone would be able to help me on this one.
Thanks in advance.