k2webfusion
Fri 2nd Aug '02, 12:34am
I'm trying to query a user field table, field6 specifically. This is a user profile field I setup for members to tell us what type of boat they have (brands like Cigarette, Wellcraft, Sonic, etc.). The query below tells me how many members have boats by excluding entries like none, na, no, n/a. (Otherwise the entry is the brand of boat.)
// How Many Total Boats
$totalboats =$DB_site->query_first('select count(*)AS totalboats
FROM userfield
WHERE field6 <> "n/a" AND field6 <> "n"');
$totalboats=$totalboats['totalboats'];
But now I need to look and count up how many are Cigarettes, Scarabs, Sonics, etc.
//Counting the brands
$cigbrand=$DB_site->query_first('select count(*)AS cigbrand
FROM userfield
WHERE field6 = "cigarette"');
$cigbrand=$cigbrand['cigbrand'];
This could be replicated for each brand I want to search for, then use PHP to do the math for me? There would seem to be an easier way to count all the boats, and also count by brand, eliminating the "none, na, n/a, still looking" entries some of our site members have entered. I'm lost on the syntax piece using the WHERE variables which may hold the key to getting all of this in one query. Any ideas?
// How Many Total Boats
$totalboats =$DB_site->query_first('select count(*)AS totalboats
FROM userfield
WHERE field6 <> "n/a" AND field6 <> "n"');
$totalboats=$totalboats['totalboats'];
But now I need to look and count up how many are Cigarettes, Scarabs, Sonics, etc.
//Counting the brands
$cigbrand=$DB_site->query_first('select count(*)AS cigbrand
FROM userfield
WHERE field6 = "cigarette"');
$cigbrand=$cigbrand['cigbrand'];
This could be replicated for each brand I want to search for, then use PHP to do the math for me? There would seem to be an easier way to count all the boats, and also count by brand, eliminating the "none, na, n/a, still looking" entries some of our site members have entered. I'm lost on the syntax piece using the WHERE variables which may hold the key to getting all of this in one query. Any ideas?