PDA

View Full Version : show first record, then a list for the rest


Psybernaut
09-03-2007, 08:20 PM
Hi Guys,

Can someone please point me in the right direction. I'm sure there is a relatively simple solution for this but I can't quite wrap my head around it.

Basically I have a list of article in the database. I want to show the most recent one in full (This is no problem, I have ordered the result by date and only show the first record), but I also want to show just the heading and date of all the other articles below it, obviously excluding the first record which is already shown. I thought perhaps I should use a second SELECT statement with a LIMIT clause, something like LIMIT 2,999999 so that it will always be greater than the total number of articles.

Am I barking up the wrong tree?

owner
09-03-2007, 08:40 PM
Do you have msn? If so pm me your email and I will try to help you out.

davidj
09-04-2007, 08:28 AM
let me know if this gets resolved

Psybernaut
09-04-2007, 12:43 PM
Haven't had a chance to chat with 'owner' yet but the LIMIT 1,999999 idea does work although this requires two SELECT's (one for the article, one for the list) with different filters from the same table which seemed like an unnecessary duplication. I just thought there was probably a much cleaner way to do it.

domedia
09-04-2007, 06:23 PM
If you can resolve this in the forum, instead of IM, other members will get some help as well. 8)

petersson
09-12-2007, 08:17 AM
I think you have to do two recordset. One for the latest and one for the headings. On the heading recordset you put a repeat region.

Psybernaut
09-12-2007, 09:53 AM
Yes, that is exactly what I did. I used one SELECT statement (Recordset) for the full article and one for the listing, using a LIMIT clause to remove the first record...


SELECT *
FROM newsletter
ORDER BY newsletter.`date` DESC

SELECT *
FROM newsletter
ORDER BY newsletter.`date` DESC LIMIT 1,999999


I just thought maybe there was a more 'streamlined' way to do it, which only required the data to be pulled out once, but this method works fine.

petersson
09-12-2007, 10:26 AM
Glad you solved it.

edbr
09-12-2007, 10:43 AM
i would have thought ( not that i know) but one select and one echo result and then another echo result in a do loop with conditions, producing more. Any of these methods would repeat the first record though. I think