Help with only showing values above 0 [RESOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spec36
Forum Commoner
Posts: 28
Joined: Thu Nov 19, 2009 6:07 pm

Help with only showing values above 0 [RESOLVED]

Post by spec36 »

This mysql query grabs 2 specific error codes from my database.

Code: Select all

$query = "select '4444' as 'error code', count(*) as 'total' from table where desc like '%error: 4444%'
union select '5555' as 'error code', count(*) as 'total' from table where desc like '%error: 5555%'
This code outputs the data from the mysql query to the screen.

Code: Select all

$i= 0;
 
 while ($i < $num) {
 $row =  mysql_fetch_array($result);
 
 echo "<B> $row[0] Errors: </b>";
 echo $row[1], "<br />";
 $i++;
 }
Example Output:
444 Errors: 0
555 Errors: 13

I only want the output to show values that are greater than 0, anything that has the value 0 I do not want to be listed on the output.

Example Output of what I want:
555 Errors: 13

Any help on how to do this would be great, as I am still a php/mysql newb.

Thanks
Last edited by spec36 on Tue Jul 06, 2010 1:51 pm, edited 1 time in total.
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Help with only showing values above 0

Post by shawngoldw »

how about

Code: Select all

if($row[1]>0) {  
  echo "<B> $row[0] Errors: </b>";
  echo $row[1], "<br />";
}
or add a where FIELD > 0 in the query.
spec36
Forum Commoner
Posts: 28
Joined: Thu Nov 19, 2009 6:07 pm

Re: Help with only showing values above 0

Post by spec36 »

Ah, I was so close. Thanks for the help this works now.
Post Reply