Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: PHP  |  size: 0.30 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <?php
  3.  
  4. $stmt = "SELECT * FROM `tbl` ORDER BY `date` ASC";
  5. $res = mysql_query($stmt);
  6. $output = array();
  7. while($row = mysql_fetch_assoc($res)){
  8.     $output[substr($row['date'], 0, 4)][] = $row;
  9. }
  10.  
  11. foreach($output as $date=>$rows){
  12.     foreach($rows as $row){
  13.         var_dump($row);
  14.     }
  15. }
  16.  
  17. ?>