View Single Post
Old 02-27-2008, 01:19 PM   #1 (permalink)
elite
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default Count number of fields != 0

I have a table as follows

account
date
item1_0
item1_1
item1_2
item2_0
item2_1
item2_2

The item fields default to zero but can be any number

Now, what I want to do is something like this - but using sql:

PHP Code:
<?php
$count 
0;
foreach(
$item as $i)
{
    if(
$i != 0)
    {
        
$count++;
    }
}
return 
$count;
?>

Any pointers would be greatly appreciated
elite is offline   Reply With Quote
Sponsored Links