Jump to content

Split into day


cordoprod

Recommended Posts

select all records, including the timestamp as a date, group by that date and sort by that date DESCENDING, then loop over the results, keeping track of the current date. when the date changes, add a new row with 'Sunday 25th of May 2008', then continue displaying records.

 

Link to comment
Share on other sites

<?
          $db = new DbConnector();
	  $db->connect();
	  
	  $sql = "SELECT * FROM travek_logg GROUP BY time SORT BY time DESC";
	  $result = $db->query($sql);
	  
	  while($fetch = mysql_fetch_array($result)) {
	     
	  }
	  
	  ?>

 

Now i don't have a clue... and am pretty sure the query is wrong..

Link to comment
Share on other sites

<?
          $db = new DbConnector();
	  $db->connect();
	  
	  $sql = "SELECT * FROM travek_logg GROUP BY time ORDER BY time DESC";
	  $result = $db->query($sql);
	  
	  $day = "yes";
	  while($fetch = mysql_fetch_array($result)) {
	  if($day != "no") date("l", $fetch['time']);
	      echo "<br>".$fetch['nick'];
		  
		 $day = "no";
	  }
	  
	  ?>

 

The output will be:

glenn

heihei

 

- No day...

Link to comment
Share on other sites

yeah how?

 

Like this?

<?
          $db = new DbConnector();
	  $db->connect();
	  
	  $sql = "SELECT * FROM travek_logg GROUP BY time ORDER BY time DESC";
	  $result = $db->query($sql);
	  
	  $day = "yes";
	  while($fetch = mysql_fetch_array($result)) {
	  if($day != "no" && $day2 != date("l", $fetch['time'])) echo date("l", $fetch['time']);
	      echo "<br>".$fetch['nick'];
		  
		 $day = "no";
		 $day2 = date("l", $fetch['time']);
	  }
	  
	  ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.