[wplug] MySQL help

Kevin Squire gentgeen at wikiak.org
Tue Nov 2 16:59:02 EDT 2010


Thanks.. that got me heading down the right road


On Mon, 1 Nov 2010 10:23:10 -0400
Bill Moran <wmoran at potentialtech.com> wrote:

> 
> If you just do:
> SELECT * FROM cur_month ORDER BY username, dstamp;
> 
> You can then do a PHP loop like:
> $cur_uname = null;
> $next = array();
> while ($row = mysql_fetch_assoc()) {
>  if ($row['username'] != $cur_uname) {
>   // Store or output the old value of $next (which is a complete CSV
> row) $next = array();
>   $next['username'] = $row['username'];
>   $cur_name = $row['username'];
>  }
>  $next[$dstamp] = true;
> }
> 
> So when the if statement fires, you have a complete row with all the
> records for that particular username, and you can do whatever you want
> to do with it (output, save to a file, put in another array ...
> whatever)
> 
> In that way, you'll build all the date for each username.
> 


-- 
http://www.wikiak.org

#############################################################
 Associate yourself with men of good quality if you esteem    
 your own reputation; for 'tis better to be alone then in bad 
 company.        - George Washington, Rules of Civility


More information about the wplug mailing list