Re: Table statistics

From: Date: Sun, 16 Nov 2003 12:32:19 +0000
Subject: Re: Table statistics
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-169817@lists.php.net to get a copy of this message
By the way, while I write the message I forgot to correct the "2 dimentional array" to "array"... Context is everything, :) -- Kim Steinhaug --------------------------------------------------------------- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --------------------------------------------------------------- "Kim Steinhaug" <kim@steinhaug.com> wrote in message news:20031116122444.66734.qmail@pb1.pair.com... > Well, Im about to create some statistics systems myself and havnt really > starter > thinking of the "optimal" way of doing such calculations so this thread will > be much > interesting. > > I would suggest the following : > > As you have already pulled out all the data from that month, we need to > prosess this. > I would create a 2 dimensional array for every Screen_ Name, > > // Initiate array > $count = array(); > > // Loop through your data and assign all the users like this > $count[$Screen_ Name] = 0; > > This will give you an array of all the users, then you could loop through > the data again and > add 1 for each instance of the user to meassure the counts : > $count[$Screen_ Name]++; > > Finally you sort the array and print out the first 5. > > (The 2 last steps should be put together since its no use going through the > data twice) > > -- > Kim Steinhaug > --------------------------------------------------------------- > There are 10 types of people when it comes to binary numbers: > those who understand them, and those who don't. > --------------------------------------------------------------- > > > "Daniel Harik" <lists@dharik.com> wrote in message > news:20031116141422.73829168.lists@dharik.com... > > Hello, > > > > I have table with messages, and i have users table, the are linked via PK > > UserID -> UserID, what i need is to select Messages for current month and > > calculate top 5 posters list for current month. > > > > I have create following query but it's not complete: > > > > SELECT Handle, Screen_Name from MBoard where Message_Date>='2003-11-00' > ORDER BY Handle; > > > > this gets me all messages posted this month ordered by userid > > > > > > Thank You.

« previous php.general (#169817) next »