Re: Generating results of a survey

From: Date: Fri, 04 Aug 2000 07:28:01 +0000
Subject: Re: Generating results of a survey
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-10073@lists.php.net to get a copy of this message
On Fri, Aug 04, 2000 at 11:49:56AM +0930, David Robley wrote: > On 3 Aug, Mike Tuller wrote: > > Hello all, > > Can anyone point me to an example of how to display the results of a survey > > where the data is stored in MySql with everything calculated. I can't seem > > to find anything in any of my books or on the web. > > > > Example output would be something like: > > > > Did you enjoy the class? > > yes 50 no 10 > > > > > > Thanks, > > Mike > > > > > Very simply, use COUNT. > > A query like SELECT COUNT(*) AS yay FROM table WHERE vote='YES' > > will return one row with one field yay containing the number of 'yes' > votes. SELECT vote, count(*) AS cnt FROM table GROUP BY vote; will return two rows, of the form: vote | cnt ----------- yes | 50 no | 10 -- Adam Haberlach | "A farm tractor is not a motorcycle." adam@newsnipple.com | --California DMV 1999 Motorcycle Driver Handbook http://www.newsnipple.com/ |

« previous php.general (#10073) next »