Set pagination, on $result1
are fetching all rows from table and, $new_result
set its LIMIT.
But i got an error "Fatal error: Call to a member function fetch_assoc()
on a non-object in /home/
...."
$page_limit = 28;
$table_name_3 = 'table';
if (!isset($_GET['page']) )
{ $start=0; } else
{ $start = ($_GET['page'] - 1) * $page_limit; }
$mysqli = new mysqli("xxxxxxx" , "xxxxxxx" , "xxxxxxx" , "xxxxxxxxx");
$result1 = $mysqli->query( "SELECT * FROM $table_name_3
WHERE `categories` LIKE '$newq'
AND `inStock` LIKE 'true' ");
while ( $rows = $result1->fetch_assoc() ) {
$new_result = $mysqli->query( $rows . "LIMIT $start,$page_limit " );
while ( $rows = $new_result->fetch_assoc() ) {
$total = mysqli_num_rows($result);
$store = $rows['store'];
$productId = $rows['productId'];
This is not the right way to do it, as your
$rows
object contains an array of fetched results ->$row['columnname']
,$row['columnname2']
and so on. Instead, use it in one query :