我有两个文件:第一个是命名semester_1.php
的,第二个是命名的pagination.php
。我正在尝试将主题的值从 to 传递semester_1.php
到pagination.php
然后查询和输出它。我使用 javascript 和 Ajax 来获取 href 的值,然后将其传递给另一个文件,即pagination.php
. 问题是我没有显示也没有错误,这是代码,有人可以帮忙吗?值得一提的是,两个文件都在同一个目录下,以防访问。
学期_1.php
<!doctype html>
<html lang="en">
<head>
<style>
.ui-tabs .ui-tabs-nav {
margin: 0;
padding: .2em .2em 0;
height: 30px;
font-size: 12px;
}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
border-bottom-right-radius: 4px;
margin-left: 15px;
height: 520px;
}
</style>
<meta charset="utf-8" />
<title>jQuery UI Tabs - Default functionality</title>
<link rel="stylesheet" href="pagenation.css" type="text/css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<script>
$(function(){
$('div#tabs ul li a').click(function() {
var n = $(this).attr('href');
var p = n.slice(5, 6);
$.ajax({
type: 'post',
url: 'pagenation.php',
data: {value : p},
success: function(data) {
// Do something with response 'data'
}
});
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#sub=1">Introduction to Programming</a></li>
<li><a href="#sub=2">Fundamental of Programming</a></li>
<li><a href="#sub=3">Afghan History</a></li>
<li><a href="#sub=4">Mathematics</a></li>
<li><a href="#sub=5">Islamic Study</a></li>
<li><a href="#sub=6">English</a></li>
</ul>
<div id="sub=1">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=2">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=3">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=4">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=5">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=6">
<br><br>
<?php include('pagenation.php');?>
</div>
</div>
</body>
</html>
分页.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Papermashup.com | PHP Pagination</title>
<link rel="stylesheet" href="css/pagenation.css" type="text/css" />
</head>
<body>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "LMS";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to database");
mysql_select_db($dbname);
$tableName="presentation";
$targetpage = "Lecture.php";
$limit = 10;
$query = "SELECT COUNT(*) as num FROM $tableName";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$stages = 3;
$page = mysql_escape_string($_GET['page']);
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
// Get page data
$data = $_POST['value'];
$query1 = "SELECT * FROM $tableName WHERE Sub_ID='$data' LIMIT $start, $limit";
$result = mysql_query($query1) or die(mysql_error());
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
$paginate = '';
if($lastpage > 1)
{
$paginate .= "<div class='paginate'>";
// Previous
if ($page > 1){
$paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
}else{
$paginate.= "<span class='disabled'>previous</span>"; }
// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
$paginate.= "...";
$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
}
// End only hide early pages
else
{
$paginate.= "<a href='$targetpage?page=1'>1</a>";
$paginate.= "<a href='$targetpage?page=2'>2</a>";
$paginate.= "...";
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "<span class='current'>$counter</span>";
}else{
$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}
}
}
}
// Next
if ($page < $counter - 1){
$paginate.= "<a href='$targetpage?page=$next'>next</a>";
}else{
$paginate.= "<span class='disabled'>next</span>";
}
$paginate.= "</div>";
}
//echo $total_pages.' Results';
// pagination
echo $paginate;
?>
<?php
$data = $_POST['value'];
while($row=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $row['Pre_Name']; ?></td>
<td><?php echo $row['pdesc']; ?></td>
<td><?php echo $row['pdatein']; ?></td>
<td><?php echo "<a href='{$row['Path']}' title='download file' target='_blank' >Download</a><br />"?></td>
</tr>
<?php }
?>
</body>
</html>