Breaking results into week blocks


Posted on 16th Feb 2014 07:03 pm by admin

I have a set of dates (and times), which are returned from a mySQL query.

These usually span from 1-2 months and I need to be able to separate the results (using HTML) every sunday (monday being the start of the week).

Set of timestamps....
Code: [Select]1255482000
1255483800
1255485600
1255487400
1256086800
1256088600
1256090400
1256092200
1256691600
1256693400
1256695200
1256697000
1257300000
1257301800
1257303600
1257305400
1257904800
1257906600
1257908400
1257910200
1258509600
1258511400
1258513200
1258515000
1259114400
1259116200
1259118000
1259119800

Currently the code looks like this, but having trouble getting round the logic of doing this...

Code: [Select]<?php
while ($sqlresults = mysql_fetch_array($results)) {
$compare = strtotime(date('d F Y',$laststamp)." next Sunday");

echo $sqlresults['timestamp'].'
';
if ($sqlresults['timestamp'] != $laststamp) {
if ($compare > $laststamp) {
#HTML CODE
}
}

$laststamp = $sqlresults['timestamp'];
}
?>

But at the moment it just puts HTML code inbetween every time

No comments posted yet

Your Answer:

Login to answer
101 Like 42 Dislike
Previous forums Next forums
Other forums

phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";

i have no idea why this isn't working
Code: <?php
session_start();
include("connect.php");

error_reporting(E

email CODING Problem
Email coding problem.

I need to send a section of the info to $tf and the same as a Cc to $em

Basic Forum Tutorial
Hi, I'm new to PHP. I want to build a basic forum for my site using PHP and MySQL. I've searched t

Warning message
I've put a website that I was doing live and I'm getting this warning message when I try to add a ne

Pagination
Hi All,

I think I'm finally getting somewhere with pagination!

I can now submit a quer

php file erros / need help please
Hello

Someone decoded a zend file for me.. after uploaded it on ftp i get some errors, i trye

Is it possible to view php source code??
Hi All

I was just wondering if it's possible to view a websites php source code?
I know

function to return url
Hi,

Can you guys help me giving a function that takes all the contents in a particular field

Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.

I am able to display data

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash