Re: Where to handle no results
| From: | Digital Hit Entertainment | Date: | Tue, 04 Jul 2000 04:55:30 +0000 |
| Subject: | Re: Where to handle no results | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4680@lists.php.net to get a copy of this message | ||
> if($numrows != 0):
> do wonderful things
> endif;
Strangely, that didn't work for me either. I ended up just checking for
one of the fields and if that returned something I did the full query:
$query = "SELECT article_id, headline, date, celebs FROM news WHERE
celebs LIKE '%$celeb%' ORDER BY date DESC";
$result = @odbc_exec($connect, $query);
if (@odbc_result($result, date) == 0) {
@odbc_close($connect);
}
else {
$result = @odbc_exec($connect, $query);
echo "<div align=\"right\"><table align=\"right\"
width=\"150\"
bgcolor=\"#010184\" border=\"0\" cellspacing=\"1\"
cellpadding=\"2\">\n";
echo "<tr><td bgcolor=\"white\" class=\"ln\"
valign=\"top\"
align=\"left\"><b>Recent Headlines</b><br />";
while (@odbc_fetch_row($result)) {
$topheadline = @odbc_result($result, headline);
$id = @odbc_result($result, article_id);
echo ("<a href=\"/news/story.shtml/$id\">$topheadline</a><br
/>\n");
$topnews++;
if ($topnews > 5) {
@odbc_close($connect);
break;
}
}
echo "</td></tr></table></div>";
@odbc_close($connect);
}
Seems to be working.
--
Ian Evans