Jump to content

dynamic selection of content - ermm... help!


stuart.cole

Recommended Posts

Hi

I am building a news delivery site - with the news being delivered in 3 areas. The first should have the latest news item, the second area the second most recent item, and the third area, latest stories 3-7.

How can I get PHP to select the last item, next to last, and then 3-7 since the ID's of these items will change as new items are added all the time?

I know there is probably a very simple answer to this - but I've not found one yet :(
Link to comment
https://forums.phpfreaks.com/topic/23561-dynamic-selection-of-content-ermm-help/
Share on other sites

Like so:

Area 1: Latest
[code]<?php
$query = 'SELECT * FROM "news" ORDER BY "date" DESC LIMIT 0,1';
?>[/code]

Area 2: 2nd Latest
[code]<?php
$query = 'SELECT * FROM "news" ORDER BY "date" DESC LIMIT 1,1';
?>[/code]

Area 3: Results 3 to 7
[code]<?php
$query = 'SELECT * FROM "news" ORDER BY "date" DESC LIMIT 2,5';
?>[/code]

...replacing [code=php:0]'news'[/code] and [code=php:0]'date'[/code] with whatever your columns are named. You might also want to read the suggested documentation to know how everything works. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.