php or sql problem?

admin

Administrator
Staff member
i posted this in another thread, but i'm not sure i made it clear what my problem is...i'm not sure if this is a problem that can be solved by a sql statement, or by php.

say i have a database that stores news articles. lets say i have the following entries

news1 12.4.01
news2 12.4.01
news3 12.4.01
news4 11.20.01
news5 11.19.01
news6 10.7.01
news7 10.6.01
news8 9.25.01
news9 8.20.01
news10 8.20.01

now, i want to display the last five entries, based on date, meaning the last 5 unique dates..so i would want all the news from 12.4.01 to show up, 11.20.01, 11.19.01, 10.7.01, and 10.6.01. I always want the last 5 dates, and also want to display all the articles that have the same date.

i've tried code like
SELECT * from impactupdate WHERE date BETWEEN '$lastime' and '$lasttime' - 5"
but of course, that doesn't work because it gets the the last 5 days from the last time the database was updated..but as you can see, it's not always 5 consecutive days. Any help would be appreciated.
 
Back
Top