Jump to content

[SOLVED] PHP/SQL Limit 5-10? How can I do it?


Guardian-Mage

Recommended Posts

I am developing some software that is backed my MySQL/PHP. I need it so that one of my sql statements will extract only rows 5 through 10. Here is what I have now

 

#Now we need to fill that array
$query1 = "SELECT news_id,news_name,news_created,news_poster,news_comments,news_read,news_content FROM
		portal_news ORDER BY ABS(news_id) DESC LIMIT " . PORTAL_DISPLAY_NEWS_MAX;
$execute1 = mysql_query($query1) or die("Unable to execute MySQL Query 1 in /portal/index.php");
$x = 0;
while ($row = mysql_fetch_row($execute1))
{
     $news[$x] = array($row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6]); #News ID
     $x++;
}

 

Where PORTAL_DISPLAY_NEWS_MAX = 5; This works fine to extract the latest 5 articles, but I need more control. Something like limit 5-10

Link to comment
https://forums.phpfreaks.com/topic/67905-solved-phpsql-limit-5-10-how-can-i-do-it/
Share on other sites

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.