Jump to content

Breaking up MySQL results with PHP


skyer2000

Recommended Posts

I have the following MySQL query

 

SELECT * FROM table ORDER BY formtimestamp

 

There are about 10-20 rows that have the same formtimestamp, and I want those to be seperated visually form the other formtimestamps (with new lists). However, when this pulls in results, everything is clumped together.

 

Is there a way in PHP that will make a break when the formtimestamp changes?

Link to comment
https://forums.phpfreaks.com/topic/97130-breaking-up-mysql-results-with-php/
Share on other sites

the code would look like...

 

<?php
  $sql = "SELECT * FROM table ORDER BY formtimestamp";
  $result = mysql_query($sql);
  $last = null;
  while($row = mysql_fetch_assoc($row)){
    if($last && $row['formtimestamp'] != $last){
      print "<hr>"; //Do break stuff here
      $last = $row['formtimestamp'];
    }
    //print $row stuff here
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.