jan
jan

Reputation: 125

How do i get a standard amount of articles per page?

I have this code which pulls a list of articles from my database.

    <?php $query = "SELECT pictures,brands,title,description,oldprice,newprice FROM images";
      $result = mysql_query($query) or die ("can't enter into DATABASE!");

    while($rij = mysql_fetch_array($result)){

        $pics = $rij["pictures"];
      echo "<p><img src=\"$pics\" /></p>"." <h3>
      | ".$rij['merken']." |</h3> ".$rij['title']." | ".$rij['description']." | <b>old price:</b> €".$rij['oldprice']." 
      | <b>new price:</b> €".$rij['newprice']."<hr/><br/>";

     }
?>

Now this script is displaying all 10 articles in my database on one page. But what i want to achieve is to display a maximum of 5 articles per page. So 50 articles should result into 10 pages.

Upvotes: 0

Views: 105

Answers (1)

Will Chesterfield
Will Chesterfield

Reputation: 1780

Look at OFFSET and LIMIT for MySQL:

See: http://www.petefreitag.com/item/451.cfm

Upvotes: 1

Related Questions