I have been trying to resolve a paging problem and I do not understand the following code.
$lstart = ($page * 6) -6;
$lend = ($page * 6)-1;
$limit = $lstart.','.$lend;
The results I get are mixed. I should get six articles per page, but it is inconsistent. The code is incorporated in a script I inherited from someone else and I am trying to fix it. Can someone explain this code to me? In the query, LIMIT=$limit.
It should be…
The second clause in limit declares how many items. Not up to a certain point.
From mysql docs: (copy/paste)
So, 1,10 would be rows 2-11
Thus, to get row 1, you need to set the offset to zero: 0,10 which would give you rows 1-10.
You can also check out further tutorials on LIMIT here: http://php.about.com/od/mysqlcommands/g/Limit_sql.htm
Code with explanation.