0
I have a problem I have a database that I use for testing where there is 1000 record and I have a website that pulls this data to be presented. I am using paging in my query this way
$read->FullRead("SELECT * FROM teste LIMIT $p , $qt_por_pg");
In php file you have the following variables
$p = $_GET['p'];
$qt_por_pg = 20;
I receive via GET
the number of the page. And I defined that I want 20 results per page the whole system is working except for a detail where it pulls the 1000 results so I want to set a limit of 100 results and not 1000 as I already use the LIMIT to make the paging as I could set this limit.
The
LIMIT
only the number of records indicated byoffset
which is the value to follow the comma, in your case only 20. Now if$p
indicates the page you want to just start on the first record of that page which is$p*$qt_por_pg
– Isac
so that you can understand in the database have 1000 records using LIMIT 1 , 20 it will catch from record 1 to the right 20 and if I pass the value LIMIT 2 , 20 it will take from record 2 till and walk over 20 and so on until you get to thousand sure so I want to set a maximum limit of 100 record and not a thousand something like LIMIT $p , $qt_por_pg LIMIT 100
– diogo Dsa
This does not exist. Each select is a separate query. Soon each query brings only 20 records, and the general rule is that it makes sense as they usually only get one page at a time as the user navigates them. If you want to get several pages soon you have to make a query that get the 100 records and page "manually"
– Isac
Mysql already accepts offset takes full syntax.
– alxwca