Not sure if this will work, but hopefully its along the right lines:
SQL code:
SELECT id, SUM(questiontext IN (...)) AS match_count
FROM mytable
WHERE surveyid = 1
GROUP BY id
Basically, you just get all rows with a matching surveyid and count the number of matching questions.
Then you just use the query's recordcount to supply you with the first count. (which in PHP I think you use the sizeof() function for)
But like I said, I'm not sure that SQL is the precise right way of doing it.
EDITED: 17 Aug 2006 17:34 by BOUGHTONP