prepare($query); $result->bind_param('ii', $firstvisiblerow, $rowscount); $result->execute(); // get data and store in a json array /* bind result variables */ $result->bind_result($OrderID, $OrderDate, $ShippedDate, $ShipName, $ShipAddress, $ShipCity, $ShipCountry); /* fetch values */ while ($result->fetch()) { $orders[] = array( 'OrderID' => $OrderID, 'OrderDate' => $OrderDate, 'ShippedDate' => $ShippedDate, 'ShipName' => $ShipName, 'ShipAddress' => $ShipAddress, 'ShipCity' => $ShipCity, 'ShipCountry' => $ShipCountry ); } $result = $mysqli->prepare("SELECT FOUND_ROWS()"); $result->execute(); $result->bind_result($total_rows); $result->fetch(); $data[] = array( 'TotalRows' => $total_rows, 'Rows' => $orders ); echo json_encode($data); /* close statement */ $result->close(); /* close connection */ $mysqli->close(); ?>