Forum Moderators: coopster

Message Too Old, No Replies

Hierarchies in displaying results

DATE post, post , post; DATE post, post, post - how?

         

Skitso

5:07 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



title error: Hierarchies in RETRIEVING results

I am automating a links site so that I only have to type a little and the links show up. as is I can add stuff to the database, but have to manually code the HTML for my front page of the last 30 updates.

I have completed the project, but I need one more thing done and I don't know how to do it.

What I want to do is list everything submitted under a certain day.

EXAMPLE:
(--- = space)

Wednesday, June 02nd, 2004
---Link
---Descr

Tuesday, June 01st, 2004
---Link
---Descr

---Link
---Descr

---Link
---Descr

Right now I use dates in this format: 27-12-2003 (dd-mm-yy). If a unix time stamp would be easier I can switch to that. I prefer timestamps, but the framework I based my links system off of didn't use it.

I know I should use loops, but I ran amuck with 'em. I tried several different ways. The best I could get was a display of one day, then the 30 entries.

Any ideas on how to do this right?

coopster

11:32 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Skitso!

When you retrieve information from the database table(s), you'll have what seems to be three columns returned...

date 
Link
Descr
...so all you would need to do is check within your result set loop to see if the date changed, and format accordingly.

What is it you are stuck on, exactly?

Skitso

6:19 pm on Jun 5, 2004 (gmt 0)

10+ Year Member




<?PHP
//------------------------------------------------------
/*
What I have at this point
http://www.webmasterworld.com/forum88/3969.htm
*/

Print '<dl>';

$sql_text = "SELECT * FROM skl_track GROUP BY 'adddate' ORDER BY 'id' DESC";
$data = $sql->Select($sql_text);
$entries = count($data);
if ($entries <= '30') {
$start = 0;
}else{
$start = $entries - 30;
}
for ($i=$start;$i<count($data);$i++) {
$date = $data[$i]['adddate'];
Print"$date";

$sql_text2 = "SELECT * FROM skl_track WHERE adddate='$date' ORDER BY 'id' DESC LIMIT $start , 30";
$data2 = $sql->Select($sql_text2);
for ($i2=$start;$i2<count($data2);$i2++) {
$id = $data2[$i2]['id'];
$category = $data2[$i2]['catid'];
$date = $data2[$i2]['adddate'];
$views = $data2[$i2]['visits'];
$linkname = $data2[$i2]['linkname'];
$descr = $data2[$i2]['descr'];
//Prints entry
Print"
<dd><p>#$i2</p>
Link Name: $linkname<br />
Link Tracking ID: ".maketrackinglink($id)."</br />
Link Description: $descr<br />
Added in: ".catname($category)."
<br /><br /></dd>";
}

}

Print '</dl>';

?>


Hey,
Thanks for the response. I know a little PHP, enough to build a simple website, but I just don't have a firm grasp on loops and complicated programming (hence I'm no programmer) - but I did try. Like I said I got caught up.

What happens is (I think) for 30 dates this thing will display 30 links under each date.

What I'm trying to do is display only 30 links total, with date headlines above each grouping of a date.

If you think you can de confuse me, I give you permission to explain this to me in idiot-terms and I won't get pissed because I am an idiot at this :)

Thanks sooo much!

[edited by: jatar_k at 9:12 pm (utc) on June 5, 2004]
[edit reason] fixed sidescroll [/edit]