我有一个基于PHP的页码系统, 运作良好, 我使用 Get 参数通过页码 :
<?php
$db = mysql_select_db($database,$connection) or trigger_error("SQL", E_USER_ERROR);
$sql1 = "SELECT COUNT(*) FROM $table";
$result1 = mysql_query($sql1, $connection) or trigger_error("SQL", E_USER_ERROR);
$row = mysql_fetch_row($result1);
$numrows = $row[0];
$rowsperpage = 2;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET[ page ]) && is_numeric($_GET[ page ])) {
$currentpage = (int) $_GET[ page ];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;
$sql2 = "SELECT * FROM internet_security ORDER BY id DESC LIMIT $offset, $rowsperpage";
$result2 = mysql_query($sql2, $connection) or trigger_error("SQL", E_USER_ERROR);
$list = mysql_fetch_assoc($result2);
$startrow = ($currentpage-1) * $rowsperpage;
?>
我展示链接的方式是这样的:
h3>Results <?php echo ($startrow+1) ?> - <?php echo min($startrow + $rowsperpage, $row) ?> of <?php echo ($totalpages *$rowsperpage) ?></h3>
<ul><?php
if ($currentpage!=$totalpages) {
echo " <li><a href= {$_SERVER[ PHP_SELF ]}?page=$totalpages >$totalpages</a></li> ";
$nextpage = $currentpage + 1;
echo " <li><a href= {$_SERVER[ PHP_SELF ]}?page=$nextpage >Next»»</a></li> ";
}?></ul>
<ul><?php
if($currentpage<$totalpages){
for ($x = ($currentpage - 3); $x < (($currentpage + 3) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
echo " <li id= pcurrent ><a href= {$_SERVER[ PHP_SELF ]}?page=$x >$x</a></li>";
} else {
echo " <li><a href= {$_SERVER[ PHP_SELF ]}?page=$x >$x</a></li> ";
}}}
}
?> </ul>
<ul><?php
if ($currentpage > 1){
$prevpage = $currentpage - 1;
echo " <li><a href= {$_SERVER[ PHP_SELF ]}?page=$prevpage >««Prev</a></li> ";
echo "<li><a href= {$_SERVER[ PHP_SELF ]}?page=1 >1</a></li> ";
}?></ul>
这个剖面法很正常
我的问题是 < 坚固> 我的疑问是 < / 坚固 > 我现在要添加 AJAX 的功能性, 这样我就可以在射程上同时具有两个功能, 也就是说, 如果 JavaScript 被关闭, 射程将在 PHP 中工作 。
我试过这个:
$(function() {
$( #pagination ul li a, .temp ).click(function(ev) {
ev.preventDefault();
$( #temporary ).load($(this).attr( href )).modal();
});
});
但是现在,页码没有起作用,当按下页码链接时,没有发生任何情况。怎么了?