I'm trying to show an error message if there are no matching products in the database but the else statement is not showing. No errors are coming up either. Maybe there is something wrong with the if statement? Im not sure if thats correct either or if i can put a while inside an if statement?
<!DOCTYPE html>
<html>
<head>
<title> Solent E-Stores </title>
<link rel='stylesheet' type='text/css' href='styles.css'>
</head>
<body>
<h1>Solent E-Stores</h1><br>
<?php
$conn=new PDO("mysql:host=localhost;dbname=assign043;","assign043","eeThotev");
$product = $_GET["product"];
$result=$conn->query("SELECT * FROM products WHERE name='$product'");
if($row=$result == 1)
{
while($row=$result->fetch())
{
echo "Product name: ".$row['name']."<br>";
echo "Description: ".$row['description']."<br>";
echo "Manufacturer: ".$row['manufacturer']."<br>";
echo "Price: £".$row['price']."<br>";
echo "Stock Level: ".$row['stocklevel']."<br>";
echo "Age Limit: ".$row['agelimit']."<br>";
echo "<p><a href='addtobasket.php?ID=".$row['ID']."'>Add one to basket!</a></p>";
echo "<p><a href='changequantity.php?ID=".$row['ID']."'>Change quantity!</a></p>";
}
}
else
{
echo "There are no matching products!";
echo "<p> <a href='index.php'>Back to Search page!</a></p>";
}
echo "<br><br><p> <a href='basket.php'>View my basket!</a></p>";
echo "<p><a href='index.php'>Go back to Search page!</a></p>";
?>
</body>
</html>
<?php
}
?>