Re: Re: Query - Grouping Results

From: Date: Mon, 19 Mar 2001 15:45:06 +0000
Subject: Re: Re: Query - Grouping Results
References: 1 2  Groups: php.db php.general 
Request: Send a blank email to php-db+get-7599@lists.php.net to get a copy of this message
> Doesn't seem to work, how would I print that out with PHP? The results will come back sorted by name, then time. While processing each row, you'll need to keep track of when the username changes, something like this (this is just rough code, not quite valid PHP): $username = ''; while ($data = fetchrow) { if ($username != $data['name']) { $username = $data['name']; print "Logins for " . $username . "\n\n"; } print $login . "\n"; } Keep track of the current user. As you examine each record, check if it's different than the current one. If it is, save it as the current username, and print the login info. If it's the same, just print the login info. - Darryl ---------------------------------------------------------------------- Darryl Friesen, B.Sc., Programmer/Analyst Darryl.Friesen@usask.ca Education & Research Technology Services, http://gollum.usask.ca/ Department of Computing Services, University of Saskatchewan ---------------------------------------------------------------------- "Go not to the Elves for counsel, for they will say both no and yes"

« previous php.db (#7599) next »