Re: two dimension array

From: Date: Sat, 02 Sep 2000 05:44:06 +0000
Subject: Re: two dimension array
Groups: php.general 
Request: Send a blank email to php-general+get-14905@lists.php.net to get a copy of this message
Addressed to: Floyd Baker <fbaker@olm1.com> php-general@lists.php.net ** Reply to note from Floyd Baker <fbaker@olm1.com> Fri, 01 Sep 2000 18:07:15 -0400 > > Hi.. > > I need to finish this job tonight before I go away. I know there's a > lot of into available but I'm really trying to get it done as quickly > as possible.. Can someone please make it simple for me . > > I'm building a poll program which is nearly done but now I want to put > the vote counts with the names of the choices. > > In the db we have record fields by the names of pollchoice1, > pollchoice2, and pollchoice3. > > To these we assign current choice names such as yes, no, or maybe or > red, green or blue. I want to add the vote count to these fields along > with the names? > > Would someone please point to an example or lay one out? I know it > can be done but haven't worked with more than single dimension arrays > before. I don't understand the problem... What is the database structure? Are you recording all the votes, or just keeping a running total? Here is a fun query: SELECT SUM( IF( pollchoice1 = 'yes', 1, 0 )) AS Choice1_Yes, SUM( IF( pollchoice1 = 'no', 1, 0 )) AS Choice1_No, SUM( IF( pollchoice1 = 'maybe', 1, 0 )) AS Choice1_No, SUM( IF( pollchoice2 = 'red', 1, 0 )) AS Choice2_Red, SUM( IF( pollchoice2 = 'green', 1, 0 )) AS Choice2_Green, SUM( IF( pollchoice2 = 'blue', 1, 0 )) AS Choice2_Blue FROM votes; This will give you how many votes each choice got. It is not actually tested, but it should be close, for MySQL at least. Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#14905) next »