The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Categorizing posts by date
I'm trying to write a journal-type script.. The main page displays all the journal entries, organized by descending date. I want to make it so that if a user has, say, 3 posts on the same date, it will automatically organize all the posts from that day under one header. Example:
Post 1 - Jan 1st Post 2 - Jan 1st Post 3 - Jan 1st Post 4 - Jan 4th Instead of looking like that, I want it to look like this: Jan 1st -Post 1 -Post 2 -Post 3 Jan 4th -Post 4 Any ideas on how I would accomplish this? Any tips are appreciated! I've played around a tiny bit with the GROUP BY control when I'm pulling data out of the dB but I can only seem to get it to display the first rows with each different date. |
#2
|
||||
|
||||
I've had a quick try (and seeing as i'm not sure how your table is setup) and i've got a little way but sadly it's not the most efficient way - but i hope you can work around it (or someone posts an easier way to do it)
PHP Code:
|
#3
|
|||
|
|||
Thanks, but unfortunately I can't hardcode the dates. The GROUP BY function works in that it takes each different date and displays the first row of each, but it just doesn't continue and display all the other similar dates under one another.
|
#4
|
|||
|
|||
Anybody? Beuler?
|
#5
|
|||
|
|||
Use a query like "SELECT post,date FROM posts ORDER BY date", and loop through it, like
Code:
$curdate="" while ($data = mysql_fetch_object($queryresults)) { if ($data->date != $curdate) { echo '<br>'.$data->date.'<br>'; $curdate = $data->date; } echo $data->post.'<br>'; } |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|