One website at a time
I have a particular question about my PHP/mySQL database.
I have a database driven site of articles at http://www.mostlyamphigory.com/archives/
Lets say I have an article of id $aid and date $date, and I want to find out what position that article would fall if the articles were sorted by date.
The table is, of course, indexed by date, so is there a way of finding where this article falls in the index by date?
What I could do, is count the number of articles that are newer than this article, and then add one:
"SELECT COUNT(*) FROM articles WHERE date > $date"
But this, I believe, would be quite inefficient. If there were two articles with the same date, they would return the same value. Is there a better way?
At the bottom of an article, I'd like to include links to next/previous articles. I need to know where the current article falls to be able to do this.
Thanks in advance
Last edited by mmj; Apr 17, 2001 at 04:06.