Youy could use:
if(!$result) {
// Don't display
} else {
echo "Title";
}
You fill in the blanks
Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:[EMAIL PROTECTED]
http://accessingram.com
> -----Original Message-----
> From: Wendall Williams [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 07, 2003 12:34 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] determining if a query returns no value
>
>
> I'm building a resume page and I am having a problem. I need
> to query a
> table to determine if the client has any entries in that
> table. If they do,
> it needs to display the category title once then display the
> entries in
> rows. If the client has no entries for that category, it
> needs to move on
> to the next category.
>
>
> Here is a sample of the code as it is now:
>
> $result = mysql_query("SELECT showname, role, network FROM
> tbltv where id =
> $_GET[clientID]");
> if (!$result) {
> echo("<p>Error performing query: " . mysql_error() . "</p>");
> exit();
> }
> // Display the title of category
> echo("<tr bgcolor='#666666'>");
> echo("<td colspan='3'><font
> color='#FFFFFF'><b>TELEVISION</b></font></td></tr>");
> // set column vars
> $cols = array('#CCCCCC','#999999');
> $i = 0;
> // generate table row
> while ( $row = mysql_fetch_array($result) ) {
>
> echo("<tr bgcolor=" . $cols[$i++%2] . "><td>" .
> $row["showname"] .
> "</td><td>" . $row["role"] . "</td><td>" . $row["network"] .
> "</td></tr>");
>
> }
>
> You can see that the "Category Title" (in this case
> TELEVISION) is printed
> before the array is fetched. This was done to avoid
> displaying the Title
> above every row. However, if the client does not have any
> entries in this
> category, it (obviously) prints the title anyway and then
> moves on to the
> next category.
>
> What statement would say " if $result returned no value move on" ??
>
> Thanks for your help.
>
> Wendall Williams
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>