Forum Moderators: coopster
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?
When you retrieve information from the database table(s), you'll have what seems to be three columns returned...
date...so all you would need to do is check within your result set loop to see if the date changed, and format accordingly.
Link
Descr
What is it you are stuck on, exactly?
<?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>';
?>
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]