Hi Guys,
i have dynamic urls querying a Db to search for product reviews.
Most products dont have reviews yet, so i want to make the code echo "no reviews yet" if the result is blank...
I already figured out how to echo the results if there was any, here is the code:
<?
$d = ($_GET["d"]);
include 'admin/connect.php';
mysql_select_db("acne");
$query = "select * from prods where id = '$d'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
$id=$row["id"];
echo '<html><head>';
echo "<title>".($row["title"])." Reviews</title>";
$strType = $row["cat"];
$strFileName = str_replace(" ", "_", $strType);
include 'temps/head.php';
echo '<a href="products.php"><b>Products</b></a> <b>ยป</b> <a href="cat/'.$strFileName.'.html"><b>'.$strType.'</b></a> <b>ยป</b> '.($row["name"]);
}
mysql_select_db("acne");
$query = "select * from reviews where pid = '$d'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
$id=$row["id"];
echo '<div align="center"><table class="acn">';
echo '<tr><td>'.$row["rev"].'</td></tr>';
echo '<tr><td>Review by: '.$row["name"].' from '.$row[loc].'</td></tr>';
echo '<tr><td><a href="review.php?r='.($row["pid"]).'">Write Your Own Review</a></td></tr>';
echo "</table></div>";
}
include 'temps/foot.php';
?>
The second query from the table 'reviews' is the one i need to display the "if no results" message....
Anyone help? ๐