I'm trying to create a pagination system in PHP. However, my products are loaded from exact so I can't use SQL. What i was thinking is that i would have to put all the items in an array, count that and then create the pagination system. The pagination system isn't the problem, but i can't seem to find a way to count my items properly using the above stated method.
Do note that exact only gives 60 results, so i had to create something that it retrieves all the results which i implemented in the code below.
My current code:
echo "<table order='0' width='90%'>";
$offset = 0;
$run=true;
$search="";
$row_count = 0;
while($run== true){
$glas = getGLAccounts($search,$offset);
$count2 = 0;
$offset=$offset+30;
foreach($glas as $gla){
$row_count++;
if ($row_count==1)
echo "<tr>";
echo( "<td><a href='pitem.php?item=".$gla['Code']."'><br/>".
"<img src='../style/images/plant.png' width='50' height='50' /><br/>".
"".$gla['Code']."</a></br>
".$gla['Description']."<br/>
€".$gla['CostPriceStandard']."<br />
<a class='toevoeg' href='catalogus.php?art=".$gla['Code']."'>Toevoegen</a></td>"
);
$count2=$count2+1;
if ($row_count==3) {
echo "</tr>";
$row_count=0;
}
}
if($count2<30) {
$run=false;
}
}
if ($row_count>0) {
echo "</tr>";
}
echo "</table>";
$glas gets all the items but when i count glas. It counts 60 items, but keeps putting 60 on my screen which is probably because i count in a while loop. In the foreach loop it puts a bunch of 1s.
Now my question is, what is the proper way to put my items in an array and count them? And where to put it?