Jump to content

Loop through and enter <br /> when new day


defroster

Recommended Posts

Hello, I have a database where each post has a  corresponding date/time:

 

DATABASE

Post 1. 2012-08-12 18:20:15

Post 2. 2012-08-12 16:30:00

Post 3. 2012-08-11 18:20:15

Post 4. 2012-08-10 13:20:30

 

When looping through and showing the results I want to put a <br /><br /> when there is a new day , but how do I do this?

 

I can only separate them if the the exact time is same on all posts...

if ($row['date'] != $previousloopdate){
echo "<br /><br />";
}

Thanks

Link to comment
https://forums.phpfreaks.com/topic/267082-loop-through-and-enter-when-new-day/
Share on other sites

Thanks for answer. I have been looking into these but cannot fully grasp it.. is there any way I can use code like this? But instead specify if the date is the same, regardless of time..

if ($row['date'] != $previousloopdate){
echo "<br /><br />";
}

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.