MJJLAM MJJLAM - 1 year ago 91
PHP Question

Loading fetched rows into php array

Below I am trying to send an ajax request when the page loads to get the results of the productID and productName in a given table. There are about 50k rows to be pulled and i've run into some time delay issues due to the organizing and handling of the array on the serverside(php). Looking at the code below I am able to get the first 10k rows to display on the console without a problem but when i query the entire table for all the results, the console returns a blank object, any possible workarounds for this?

function loadProducts() {
type: "POST",
data:{'x':'x' },
url: 'performanceHelper/loadProductList.php',
dataType: 'text',

success: function (result, textstatus) {
//Removing reference in Firebase
window.onload = loadProducts();

PHP code


$sql = "SELECT productID, productDesc FROM products";

$temp = $dbh->query($sql);

$results = $temp->fetchAll();

echo json_encode($results);

Answer Source

Like @RiggsFolly mentioned in the comments, what on earth do you want to do with 50000 items in the browser????

However if you have to, since you can get 10k without any issues like you mentioned, i'll suggest you try pagination... create a function to get the items by sending start and limit as parameters.

This way you dont have to send 50k items at once but you can still get your data.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download