Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

PHP pagination using associative array

PHP pagination using associative array

In this tutorial I am going to show you how to create a pagination in PHP using associative array with working tutorial.
$state=array(“Andhra Pradesh”=>”Hyderabad”,”Arunachal Pradesh”=>” Itanager”,”Assam”=>”dispur”,”Bihar”=>”Patna”,”Chhattisgarh”=>”Raipur”,”Goa”=>”Panaji”,
“Krnataka”=>”Bangalore”,”Kerala”=>”Thiruvanthapuram”,”Madhya Pradesh”=>”Bhopal”,”Maharashtra”=>”Mumbai”,”Manipur”=>”Imphal”,”Meghalaya”=> “Shillong”,”Nagaland”=>”Kohima”,”Orissa”=>”Bhubaneswar”,”Punjab”=>”Chandigarh”,
“Sikkim”=>”Gangtok”,”Rajasthan”=> “Jaipur”,”Tamil Nadu”=>”Chennai”,”Tripura”=>”Agartala”,
“Uttar Pradesh”=>”Lucknow”,”Uttarakhand”=>”Dehra Dunm”,”West Bengal”=>”Culcutta”);
<table width=”380″ border=”1″ align=”center”>
<td width=”370″ height=”23″><center>
$link_no=$_REQUEST[‘lid’];  //receive link link no which have clicked.
if(empty($link_no))   //if nothing is clicked default value of $link will 1;
$end=$link_no*5; // ending point.
$start=$end-5;// starting point
echo”<table border=’1′>”;
echo “<tr><th>State</th><th>Capital</th></tr>”;
foreach($state as $st=>$cp)
echo “<tr><td>$st</td><td>$cp</td></tr>”;
<td height=”23″>
$num_link=ceil($data/5);  //count how many link will create(5 of 5)
echo “<a href=’paging.php?lid=$i’ style=’text-decoration : none’>$i</a>”.” “;
//link generate and query string is pass.


5 1 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments

Thanks for sharing this amazing information.