Forum Moderators: coopster
if (!$limit) {
$limit = 5;
}
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' ORDER BY `id` DESC LIMIT $limit");
....and this retrieve last news by id.
What I need is to retrieve not the last news but penultimate (ex. if are 30 news, I want to get the 29 -th) or the 5 -th penultimate but not the last (ex. 30)
Can help anyone?
I think the best option would be to fetch the second row:
$result = mysql_query($query) or die(mysql_error());
mysql_data_seek($result, 1);
$row = mysql_fetch_assoc($result);
Regards
Michal
PS. If you want to retrieve the limit - 1 then use
mysql_data_seek($result, $limit - 2);