Use this in your query:
LIMIT 24
LIMIT is a MySQL function that selects a particular range of results from your query results. There are basically two ways of using it:
- By simply specifying the number of results you want to fetch, like
LIMIT 24
; or - By specifying another range in the form of
LIMIT X, Y
. WhereX
is the beginning andY
is number of rows you want to fetch, like:LIMIT 10,5
that would select the 5 results from row11
to15
In your particular case you can simply replace this line:
$query = "SELECT * FROM {$tableObject} {$sort1};";
For:
$query = "SELECT * FROM {$tableObject} {$sort1} LIMIT 24;";
or even:
$query = "SELECT * FROM {$tableObject} {$sort1} LIMIT 0,24;";
For a better understanding about how to use limit, I recommend you to read this page from MySQL manual
3
solved SQL to only fetch some rows?