Re: How to count same text results from DB?
| From: | David Newcomb | Date: | Tue, 03 Oct 2000 16:31:19 +0000 |
| Subject: | Re: How to count same text results from DB? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3269@lists.php.net to get a copy of this message | ||
Vojtech,
Take a look at:
odbc_fetch_into(..)
this will put the data from the database into an array;
David.
----- Original Message -----
From: Vojtech Dvorak <vojtech_dvorak@servind.cz>
To: David Newcomb <davidn@vnvi.com>
Cc: php-db <php-db@lists.php.net>
Sent: Tuesday, October 03, 2000 3:10 PM
Subject: Re: [PHP-DB] How to count same text results from DB?
> Clear, thanks for explanation, but I use bloody ODBC to connect bloody M$
> Access... there is missing few things such as fething data into aray...
> Vojta
>
>
>
> > > > $alldata=array();
> > > > $alldata=suck_all_data_into_an_array();
> > >
> > > Ok, so something like: $alldata=array(John, Mark, Paul, Steve,
Joseph);
> ?
> >
> > When you do a query on the database, the information is presented back
> > to you in the form of an array. Under Oracle it returns an associated
> array
> > containing/like:
> > $data[<fieldname>][<record/row number>]
> >
> > I'm not sure how MS SQL dose it but it will be similar.
> >
> > > > for ($i=0 ; $i<count($alldata) ; $i++)
> > > > {
> > > > $mycount[ $alldata["NAME"][$i] ] ++;
> > >
> > > Sorry, what this line exacly do? I have fight with arrays all the
> time...
> > do
> > > you know place where I can see some good tutorial for arrays?
> > > How the contens of this array looks like?
> >
> > It should be: $mycount[ $alldata[<fieldname>][$i] ] ++;
> >
> > This produces an associated array where the ``select''ed name is the
> index.
> > The array is populated like a historgram, to produce results like
> > $mycount["John"] = 5;
> > $mycount["Mark"] = 3;
> > $mycount["Paul"] = 2;
> > etc...
> >
> > > > do_your_stuff();
> > > > }
> > > >
> > > > reset($mycount)
> > > > while (list($k,$v) = each($mycount))
> > > > {
> > > > echo "There are $v students with the name $k<br>";
> > > > }
> >
> > Inorder to put out the information you will have to use list() and
each().
> >
> > I hope this is a bit clearer?
> > David.
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>