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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.