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

Lining up columns nicely.
Hello everyone, I'm having problems with making columns line up properly. Here is my code:

post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu

My query is being run with no results.
I have this.

Code: function DropUser($duser_id, $user_email, $user_username) {

controlling/creating accounts with privileges
hi all,
i'm trying to figure out how i can create/control account with privileges, for instance a

Call to undefined function mysql_fetch_accoc()
New to php/mysql coding. What's wrong with this sequence, or am I
just not seeing to obvious?

Variables and Include
Code: [Select]<?php

$header = $_COOKIE['mss']['header'];
$body = $_COOKIE['mss']['b

Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I

Change Age automatically
hi guys . im new to php , is it possible to change age value in mysql automatically when year change

Multithreading design
Hi

I have come up with a Singleton class that manages a pool of database connections. Basical

parse error
Parse error: syntax error, unexpected '[', expecting ')' in /Users/admin/Sites/phptest/array.php on

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