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>");
// 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

Reply via email to