Add 10 To The Limit?
I am attempting to create a dynamic LIMIT clause in an SQL query, but to no prevail.
Basically, I have a query selecting all of the posts from a table called "posts".
From there, I have a LIMIT statement saying to limit it to whatever a variable called "pages" is equaled too.
So from the above, I want it to display all of the posts that were the first 1 - 10.
$page = $_GET["page"] + 9;
$q1 = $link->query("SELECT * FROM posts ORDER BY id DESC LIMIT $page");
(The page always has a GET variable "?posts=1".)
Well, this isn't working exactly how I wanted it to work.
You see, I want it to select 1 through 10 if $pages = 1.
If pages is equaled to 2, I want it to select from 11 to 20... And so forth.
How could I do this?
You have to use OFFSET. Check this tutorial about paging using php