I'm currently doing the following, which displays banners created by such and such based on a bannerID passed through a URL:
<?php
echo "More Banners By $Credit<P>";
$sql="SELECT * FROM camb_banners WHERE Credit = \"$Credit\" ORDER BY Title";
$result=mysql_query($sql,$db);
$num = mysql_num_rows($result);
$cur = 1;
while ($num >= $cur)
{
$row = mysql_fetch_array($result);
$BannerID = $row["BannerID"];
$Title = $row["Title"];
$Date = $row["Date"];
if ($BannerID != $bannerID)
{
echo "<A HREF=index.php?bannerID=$BannerID>$Title</A><BR>";
}
$cur++;
}
?>
You can see the results by viewing:
http://www.livinglegend.org/CAMB/index.php?bannerID=1
My problem is this. I currently have it set to say:
More banners by John Doe<P>
Title1<BR>
Title2<BR>
Title3<BR>
etc.<BR>
That works great if there's actually results. But if there aren't, it says "More Banners By John Doe" and then lists nothing underneath, which looks sloppy. However, if I put "More Banners By John Doe" inside the SQL argument, it prints that sentence for ever banner listed, which looks even worse. So how can I get it to print once, but at the same time only print if there are results to print?