我正在尝试使用分页功能(php mysql和jQuery)制作目录。
我成功地创建了一个分页页面来加载mysql数据库的结果。我想添加一个侧面菜单让访问者点击以显示具有分页效果的特定结果。
我的效果:
Left side right side
Category A item-NO item-name category
Category B No.1 Item1 categoryA
Category C No.2 Item2 categoryB
No.3 Item3 categoryC
No.4 Item4 categoryA
No.5 Item5 categoryB
No.6 Item6 categoryC
No.7 Item7 categoryA
Page 1 2 3 4 5 6 7
我想点击左侧的按钮(或链接)以显示以下效果:
Left side right side
Category A item-NO item-name category
Category B NO.1 Item1 categoryA
Category C No.4 Item4 categoryA
No.7 Item7 categoryA
Page 1 2 3 4 5 6 7
我试图发挥效果但失败了。
这是我的代码:
<?php
$sql = mysql_query("select * from mytable");
$total = mysql_num_rows($sql);
$adjacents = 1;
$limit = 5;
$targetpage = "index.php";
$total_page = ceil($total/$limit);
$page = $_GET['page'];
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
$tpages = ($_GET['tpages']) ? intval($_GET['tpages']) : $total_page;
$sql2 = "SELECT * FROM mytable ORDER BY NO DESC limit $start ,$limit";
$sql_query = mysql_query($sql2);
if($page<=0) $page = 1;
if($adjacents<=0) $adjacents = 1;
$reload = $targetpage . "?";
?>
<html>
<head>
<title>My item</title>
</head>
<body>
<div class="container mtb">
<div align="center">
</div>
<div class="row">
<div class="col-md-3"><p></p>
<div class="">
<ul class="list-inline">
<li><a href="#"><small>Category A<</small></a></li>
<li><a href="#"><small>Category B</small></a></li>
<li><a href="#"><small>Category C</small></a></li>
</ul>
</div></div>
<div class="col-lg-9 col-md-9">
<div class="panel panel-default">
<div class="panel-heading">total item::<?php echo $total ?></div>
<div class="panel-body">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th class="text-center">NO</th>
<th class="text-center">item name</th>
<th class="text-center">category</th>
</tr>
</thead>
<tbody>
<?php while($curnm = mysql_fetch_array($sql_query)) {
?>
<tr>
<td class="text-center"><?php echo $curnm['NO'] ?></td>
<td class="text-center"><?php echo $curnm['item'] ?></td>
<td class="text-center"><?php echo $curnm['category'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<hr>
<?php
include("pagination3.php");
echo paginate_three($reload, $page, $tpages, $adjacents);
?>
</div>
</div>
</div>
</div></div>
</body>
</html>