Below mentioned are 3 different files 1st file Package.php code:
<body>
<form action='Add_Package.php' method='POST'>
<input type='submit' id='btnAdd' value='Add Package Details'>
<select id="pack_type" name="pack_type" onChange="package_changed()" >
<option value="1">Valid</option>
<option value="0">In-Valid</option>
</select>
<center><h1>Package Details</h1></center>
<div id="package_info" name="package_info"> </div>
<script type="text/javascript" src="js/service.js" ></script>
</body>
2nd File service.js code:
function package_changed()
{
var xmlhttp;
var type;
type=document.getElementById("pack_type").value;
if(type=="label")
return;
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("package_info").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","Package_description.php?type="+type,true);
xmlhttp.send();
}
3rd file Package_description.php code: $perpage=10;
$row_count = mysql_query("select count(package_id) from package where is_valid=".$_GET['type']);
$pages = ceil(mysql_result($row_count,0) / $perpage);
$page=(isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start=($page - 1) * $perpage;
$result = mysql_query("SELECT * FROM package where is_valid='".$_GET['type']."'ORDER BY package_id DESC LIMIT $start , $perpage ");
echo '<div class="pagination pagination-middle pagination-right"><ul>';
if($pages >= 1 && $page <=$pages)
{
for($x=1; $x<=$pages; $x++)
{
if($x==$page)
{
echo '<li class="disabled"><a href="?page='.$x.'">'.$x.'</a></li>';
}
else
{
echo '<li class="active"><a href="?page='.$x.'">'.$x.'</a></li>';
}
}
}
echo '</ul></div>';
echo " <center>
<table class='table table-hover' border=5>
<th>Package Name</th>
<th>Package Credits</th>
<th></th>";
while($row=mysql_fetch_array($result))
{
echo " <tr>
<td>" .$row['package_name'] ."</td>
<td>" .$row['package_credits'] ."</td>
<td><center><a href='Edit_Package.php?id=".$row['package_id'] . "'>Edit</a></center </td>
</tr>";
}
echo " </table><br>
</center>
</form>";
?>
Que: When I click on valid or invalid option in 1st file it will display the data properly. When the records are more than 10 then when I click on 2nd page It is not displaying the records from the 2nd page. The Problem is with javascript function because the same pagination script runs well when present on the same page here 3 different pages are involved including javascript function I don't know where exactly the problem is does any body have any solution please do let me know. Thanks in advance.