我的页面中有一个分页系统,我想添加一个文本字段和按钮来跳转页面输入值。
这是我的代码:
<?php
require_once("../dbc.php");
$sql = mysql_query("SELECT * FROM adpost WHERE usertype='b' ORDER BY postdate DESC" );
$nr = mysql_num_rows($sql);
if (isset($_GET['pn'])) {
$pn = preg_replace('#[^0-9]#i', '', $_GET['pn']);
} else {
$pn = 1;
}
$itemsPerPage = 10;
$lastPage = ceil($nr / $itemsPerPage);
if ($pn < 1) {
$pn = 1;
} else if ($pn > $lastPage) {
$pn = $lastPage;
}
$centerPages = "";
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
$centerPages .=' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&orderby='.$orderby.'">' . $add1 . '</a> ';
} else if ($pn == $lastPage) {
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&orderby='.$orderby.'">' . $sub1 . '</a> ';
$centerPages .=' <span class="pagNumActive">' . $pn . '</span> ';
} else if ($pn > 2 && $pn < ($lastPage - 1)) {
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '&orderby='.$orderby.'">' . $sub2 . '</a> ';
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&orderby='.$orderby.'">' . $sub1 . '</a> ';
$centerPages .=' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&orderby='.$orderby.'">' . $add1 . '</a> ';
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '&orderby='.$orderby.'">' . $add2 . '</a> ';
} else if ($pn > 1 && $pn < $lastPage) {
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&orderby=' . $orderby . '">' . $sub1 . '</a> ';
$centerPages .=' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .=' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&orderby='.$orderby.'">' . $add1 . '</a> ';
}
$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage;
$sql3 = "SELECT * FROM adpost WHERE usertype='b' $orderby_query $limit";
$q = mysql_query($sql3);
$paginationDisplay = "";
if ($lastPage != "1"){
$paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. ' ';
if ($pn != 1) {
$previous = $pn - 1;
$paginationDisplay .= '<a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '&orderby='.$orderby.'"><span class="back"> Back</span></a> ';
}
$paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
if ($pn != $lastPage) {
$nextPage = $pn + 1;
$paginationDisplay .= '<a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '&orderby='.$orderby.'"><span class="back"> Next</span></a> ';
}
}
这是输出:
*******************************************************************
* Total 213 | page 1 of 19 | 1 2 Next [Jump TextField]*
*******************************************************************
如何插入跳转字段和按钮?
由于