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

Error in query: Resource id #4??
hey guys, having a minor (i think) problem here that i havent been able to figure out. long story sh

Help with php code
Hello, can anyone tell me why this php word trap fails to work,
and the trigger words get blow r

session checking in page load
hai all I have a web site is www.Mryas.com in this my login page is Page1.aspx its co

Why doesn't this work? (SSH2)
This is my script:

Code: <?php
$connection = ssh2_connect('213.251.167.109', 22);

user validation always displaying invalid ? please help
Hello,

I have 2 accounts and there is a field in mysql called validated it can be either &quo

preg_match logical error
Code: <?php
$s = file_get_contents("page.html");
preg_match('/<div cla

Working with Global Variables
hi, I'm not really sure why the following code is returning a "Call to a member function getBan

database design
Hi,

I got a page which allow candidate to type in their previous working experience,
I let

PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see

Retrieving the 25 most recently added entries from all tables in a MySQL databas
Hello,

The code below works great. It creates a table that shows the 25 most recently added t

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