Forum Moderators: coopster

Message Too Old, No Replies

Advanced Graphing

Looking for tips or ideas on arranging data.

         

inveni0

2:32 am on Oct 2, 2006 (gmt 0)

10+ Year Member



I have a big fat database table full of records that include a date, a time and a value. The records look something like this:

7/7/2006 11:05 200
7/7/2006 11:10 300
7/8/2006 11:05 100
7/8/2006 11:10 50

How can I query this data and have it arranged as so:

_______ 11:05 11:10
7/7/2006 200 - 300
7/8/2006 100 - 50

(Dashes and Underscores are simply to help align the numbers visually within this post.)

My mind is about to explode on trying to figure this out! Any ideas?

I appreciate any help that I can be given.

DrDoc

3:00 am on Oct 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're gonna have to "SELECT *" and loop through it (probably in a foreach). Are the times consistent between records?

inveni0

3:06 am on Oct 2, 2006 (gmt 0)

10+ Year Member



Yes, the times will be consistent on each record (every five minutes of the day), and the dates consecutive for the most part (weekends are excluded).

inveni0

1:35 am on Oct 3, 2006 (gmt 0)

10+ Year Member



Still looking for some help on this one!

DrDoc

5:40 am on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then, since you know the minutes -- you know which headings.
SELECT * ... ORDER BY DateColumn ASC, TimeColumn ASC

If the "DateColumn" value changes, start on a new row ... otherwise print on the same row.

inveni0

8:36 pm on Oct 3, 2006 (gmt 0)

10+ Year Member



It's the code required to move on to the next row that throws me.

DrDoc

8:45 pm on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$date = "0000-00-00"; 
echo "<table><tr>";
echo "<th>Date</th>...<th>11:00</th><th>11:05</th>...";
while("loop through rows here") {
$arrFoo = "let's assume you get the row data here";
if($date!= $arrFoo['DateColumn']) {
echo "</tr><tr>";
echo "<td>" . $arrFoo['DateColumn'] . "</td>";
$date = $arrFoo['DateColumn'];
}
echo "<td>" . $arrFoo['TimeColumn'] . "</td>";
}
echo "</tr></table>";