[How to create] – Pagination Without Database MySQL on PHP

May be seen from the title of this post is not familiar to the developers of web -based software.  Make pagination is a must when we have data that can be said to be tens or even hundreds of thousands of web pages. Why should? because how could we be able to access tens or even hundreds of thousands of data on a single page. inefficient is not it?. The following simple code syntax that may be re-developed.

$data = array(
	array('001','AAA'),
	array('002','BBB'),
	array('003','CCC'),
	array('004','DDD'),
	array('005','EEE'),
	array('006','FFF'),
	array('007','GGG'),
	array('008','HHH'),
	array('009','III'),
	array('010','JJJ'),
	array('011','KKK'),
	array('012','LLL'),
	array('013','MMM'),
	array('014','NNN'),
	array('015','OOO'),
	array('016','PPP'),
	array('017','QQQ'),
	array('018','RRR'),
	array('019','SSS'),
	array('020','TTT'),
);

$batas = 10; # FOR LIMIT DATA
$halaman = @$_GET['halaman'];

if(empty($halaman)){
 $posisi = 0;
 $halaman = 1;
 $hingga = $batas;
}else{
 $posisi = ($halaman - 1) * $batas;
 $hingga = $posisi + $batas;
}

$no = $posisi + 1;
$total_data = count($data);

echo '<table cellpadding="4" cellspacing="0" border="2">
 <thead>
 <tr style="background:#000;color:#FFF;">
 <th>No</th>
 <th>Angka</th>
 <th>Huruf</th>
 </tr>
 </thead>
 <tbody>';

 while($posisi < $hingga){

 echo '<tr>
 <td align="center">'.$no.'</td>
 <td>'.$data[$posisi][0].'</td>
 <td>'.$data[$posisi][1].'</td>
 </tr>'; 

 $posisi++; 
 $no++; 
 }
 echo '</tbody>
 </table>';

$jumlah_halaman = ceil($total_data/$batas);
 
echo"<br> Halaman : ";

for($i=1; $i<=$jumlah_halaman; $i++){
 if($i != $halaman){
 echo"<a href=\"sample_paging.php?halaman=$i\">$i</a> | ";
 }else{
 echo"<b>$i</b> | ";
 }
}
 
 echo "<p>Total data : <b>$total_data</b> </p>";

Save the file sample_paging.php on your directory web server and then run in web browser.

if you click next page then display data.

hopefully useful, please try and develop with your version. Bye..bye.