Php 添加:8px 10px; 文本装饰:无;} ul.pagination li.dot{ 填充:3px 0;} ul.pagination li{ 浮动:左; 列表样式类型:无; 边距:0 3px 0;} 李:第一个孩子{ 左边距:0;} ul.pagina
添加:8px 10px; 文本装饰:无;} ul.pagination li.dot{ 填充:3px 0;} ul.pagination li{ 浮动:左; 列表样式类型:无; 边距:0 3px 0;} 李:第一个孩子{ 左边距:0;} ul.pagination li a{ 颜色:黑色; 显示:块; 填充:7px 10px; 文本装饰:无;} ul.pagination li a img{ 边框:中无;} ul.pagination li a.current{ 背景色:白色; 边界半径:0; 颜色:#333333;} ul.pagination li a.当前:悬停{ 背景色:白色;} ul.pagination li a:悬停{ 背景色:#C8D5E0;} ul.pagination li a{ 背景色:#F6F6F6; 边框颜色:#C8D5E0; 边界图像:无; 边框样式:实心; 边框宽度:1px 1px 2px; 颜色:#1E598E; 显示:块; 字体大小:粗体; 填充:8px 10px; 文本装饰:无;}Php 添加:8px 10px; 文本装饰:无;} ul.pagination li.dot{ 填充:3px 0;} ul.pagination li{ 浮动:左; 列表样式类型:无; 边距:0 3px 0;} 李:第一个孩子{ 左边距:0;} ul.pagina,php,mysql,pagination,Php,Mysql,Pagination,添加:8px 10px; 文本装饰:无;} ul.pagination li.dot{ 填充:3px 0;} ul.pagination li{ 浮动:左; 列表样式类型:无; 边距:0 3px 0;} 李:第一个孩子{ 左边距:0;} ul.pagination li a{ 颜色:黑色; 显示:块; 填充:7px 10px; 文本装饰:无;} ul.pagination li a img{ 边框:中无;} ul.pagination li a.current{ 背景色:白色; 边界半径:0;
分页{
字体系列:“Arial”,“Helvetica”,无衬线;
字体大小:13px;
身高:100%;
列表样式类型:无;
利润率:20px0;
溢出:隐藏;
填充:0;}
ul.页码li.详细信息{
背景色:白色;
边框颜色:#C8D5E0;
边界图像:无;
边框样式:实心;
边框宽度:1px 1px 2px;
颜色:#1E598E;
字体大小:粗体;
填充:8px 10px;
文本装饰:无;}
ul.pagination li.dot{
填充:3px 0;}
ul.pagination li{
浮动:左;
列表样式类型:无;
边距:0 3px 0;}
李:第一个孩子{
左边距:0;}
ul.pagination li a{
颜色:黑色;
显示:块;
填充:7px 10px;
文本装饰:无;}
ul.pagination li a img{
边框:中无;}
ul.pagination li a.current{
背景色:白色;
边界半径:0;
颜色:#333333;}
ul.pagination li a.当前:悬停{
背景色:白色;}
ul.pagination li a:悬停{
背景色:#C8D5E0;}
ul.pagination li a{
背景色:#F6F6F6;
边框颜色:#C8D5E0;
边界图像:无;
边框样式:实心;
边框宽度:1px 1px 2px;
颜色:#1E598E;
显示:块;
字体大小:粗体;
填充:8px 10px;
文本装饰:无;}
好的,我已经实现了这些更改,现在我得到的是列表中正确数量的结果,但分页中只有2页,但是当您单击第2页时,它确实会显示下一组结果。。。我在count中重复了var,但它只显示了1个结果?我在原始帖子中添加了修改后的脚本,以防你没有注意到,谢谢。。。(我想我可以包括测试页面的url,但它是托管在成人域上的,所以我认为这在这里是不可接受的)小心一个接一个的错误。我已经写了好几次分页代码,有好几个地方你需要汇总或添加一个没有立即意义的代码。现在没有一个是有意义的lol,我改变了一些计算,没有取得任何进展。。。除了确认它只从数据库中提取10行之外,我还更改了变量ageI,我将向您展示我几天前编写的分页脚本,您可以将其用作基础。我会尽快把它寄出去。现在,我更详细地查看了您的代码,我注意到您正在使用不推荐的对象…好的,我已经实现了这些更改,现在我得到的是列表中正确的结果数,但分页中只有2页,但是当您单击第2页时,它确实显示了下一组结果。。。我在count中重复了var,但它只显示了1个结果?我在原始帖子中添加了修改后的脚本,以防你没有注意到,谢谢。。。(我想我可以包括测试页面的url,但它是托管在成人域上的,所以我认为这在这里是不可接受的)小心一个接一个的错误。我已经写了好几次分页代码,有好几个地方你需要汇总或添加一个没有立即意义的代码。现在没有一个是有意义的lol,我改变了一些计算,没有取得任何进展。。。除了确认它只从数据库中提取10行之外,我还更改了变量ageI,我将向您展示我几天前编写的分页脚本,您可以将其用作基础。我会尽快把它寄出去。现在我更详细地查看了您的代码,我注意到您正在使用不推荐的对象。。。
<?php
$tstart = 0;
$tend = 0;
//$tpage = 0; // the start page
//$tpages = 0; // number of pages
$tpagelinks = ""; // stores the output pagination
$ttotal = 0; / total number of results
$trows = 5; // number of results per page
$online = ""; // stores the results to display
$dbhost = "localhost";
$dbuser = "****_models";
$dbpass = "****";
$dbcon = @mysql_connect($dbhost,$dbuser,$dbpass) or die('Database error: ' . mysql_error());
$db = mysql_select_db('****_cammodels', $dbcon) or die('Database error: ' . mysql_error());
$query = "SELECT * FROM cbmodels WHERE gender='f' AND status='Public' AND age<='22'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error() . "\nQuery: $query");
while($row = mysql_fetch_array($result))
{
$online .= "#". $ttotal . " \n";
$online .= $row['status'] . "/" . $row['name'] . "/" . $row['gender'] . "/" . $row['age'] . "\n";
$online .= "<br>\n";
$ttotal ++;
}
$tstart = ($tpage * $trows) - $trows;
$tend = $tstart + $trows;
if ($tend > $ttotal) { $tend = $ttotal; }
$tpages = floor($ttotal / $trows);
if ($ttotal % $trows != 0) { $tpages ++; }
if ($tpage > $tpages) { $tpage = 1; }
if ($tpage > 1) { $tpagelinks .= "<a class='allonlinepages_url' href='new_from_db.php?page=" . ($tpage - 1) . "'>PREVIOUS</a>\n"; }
for ($ti = 1; $ti <= $tpages; $ti ++)
{
if ($tpage == $ti) { $tpagelinks .= "$ti \n"; }
else { $tpagelinks .= "<a class='allonlinepages_url' href='new_from_db.php?page=$ti' >$ti</a>\n"; }
}
if ($tpage < $tpages) { $tpagelinks .= "<a class='allonlinepages_url' href='new_from_db.php?page=" . ($tpage + 1) . "' >NEXT</a>\n"; }
echo $online;
echo $tpagelinks;
mysql_close($dbcon);
?>
//Use mysqli object instead of mysql_xxx, better security
$db3= new mysqli($hostname, $username, $password, $dbname);
//how many records I want per page
$perPage= 9;
//I'm passing the startrecording as a Get variable in the page links
if($_GET['startingrecord']){
$startingRecord=trim($_GET['startingrecord']);
}
//but if there is no get variable, start at record zero
else {
$startingRecord=0;
}
//prepare your query
$stmt3 = $db3->prepare("SELECT DISTINCT file, category, P.productID, price, title, price * (1- sale) FROM Products AS P INNER JOIN OrderProducts AS OP ON P.productID NOT IN (Select productID from OrderProducts) Left JOIN Sale AS S on P.productID= S.ProductID ORDER BY productID DESC");
// You can bind parameters if necessary, but it's not here
//execute the query and store the result
$stmt3 -> execute();
$stmt3->store_result();
//determine the number of total rows
$numberRows= $stmt3->num_rows;
//close the db
$db3 -> close;
//Reopen with limits this time.
$db3= new mysqli($hostname, $username, $password, $dbname);
$stmt3 = $db3->prepare("SELECT DISTINCT file, category, P.productID, price, title, price * (1- sale) FROM Products AS P INNER JOIN OrderProducts AS OP ON P.productID NOT IN (Select productID from OrderProducts) Left JOIN Sale AS S on P.productID= S.ProductID ORDER BY productID DESC LIMIT ?, ?");
// bind the startingrecord from the get variable and the perpage variable.
stmt3->bind_param("ii", $startingRecord, $perPage);
//you use ceiling to make sure if that if there's a remainder, you have an extra page for the stray results
$pages= ceil($numberRows/ $perPage);
//This is me generating the page links
for ($i=1; $i<= $pages; $i++) {
if ($i==1){
$start=0;
}
else{
$start= ($i-1) * ($perPage);
}
echo "<a href='#' onclick='gallery(\"startingrecord=".$start."\")'>".$i." </a>";
}
$stmt3 -> execute();
$stmt3->store_result();
$stmt3->bind_result($file, $category2, $productID, $price, $title2, $sale);
while($stmt3->fetch()){
// do whatever you want to your result
})
<style>
ul.pagination {
font-family: "Arial", "Helvetica", sans-serif;
font-size: 13px;
height: 100%;
list-style-type: none;
margin: 20px 0;
overflow: hidden;
padding: 0; }
ul.pagination li.details {
background-color: white;
border-color: #C8D5E0;
border-image: none;
border-style: solid;
border-width: 1px 1px 2px;
color: #1E598E;
font-weight: bold;
padding: 8px 10px;
text-decoration: none; }
ul.pagination li.dot {
padding: 3px 0; }
ul.pagination li {
float: left;
list-style-type: none;
margin: 0 3px 0 0; }
ul.pagination li:first-child {
margin-left: 0; }
ul.pagination li a {
color: black;
display: block;
padding: 7px 10px;
text-decoration: none; }
ul.pagination li a img {
border: medium none; }
ul.pagination li a.current {
background-color: white;
border-radius: 0 0 0 0;
color: #333333; }
ul.pagination li a.current:hover {
background-color: white; }
ul.pagination li a:hover {
background-color: #C8D5E0; }
ul.pagination li a {
background-color: #F6F6F6;
border-color: #C8D5E0;
border-image: none;
border-style: solid;
border-width: 1px 1px 2px;
color: #1E598E;
display: block;
font-weight: bold;
padding: 8px 10px;
text-decoration: none; }
</style>
<?php
/******************************************pagination*****function*****************************************/
function pagination($per_page = 10, $page = 1, $url = '', $total){
$adjacents = "2";
$page = ($page == 0 ? 1 : $page);
$start = ($page - 1) * $per_page;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total/$per_page);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<ul class='pagination'>";
$pagination .= "<li class='details'>Page $page of $lastpage</li>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter'>$counter</a></li>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter'>$counter</a></li>";
}
$pagination.= "<li class='dot'>...</li>";
$pagination.= "<li><a href='{$url}$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='{$url}$lastpage'>$lastpage</a></li>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<li><a href='{$url}1'>1</a></li>";
$pagination.= "<li><a href='{$url}2'>2</a></li>";
$pagination.= "<li class='dot'>...</li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter'>$counter</a></li>";
}
$pagination.= "<li class='dot'>..</li>";
$pagination.= "<li><a href='{$url}$lpm1'>$lpm1</a></li>";
$pagination.= "<li><a href='{$url}$lastpage'>$lastpage</a></li>";
}
else
{
$pagination.= "<li><a href='{$url}1'>1</a></li>";
$pagination.= "<li><a href='{$url}2'>2</a></li>";
$pagination.= "<li class='dot'>..</li>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter'>$counter</a></li>";
}
}
}
if ($page < $counter - 1){
$pagination.= "<li><a href='{$url}$next'>Next</a></li>";
// $pagination.= "<li><a href='{$url}$lastpage'>Last</a></li>";
}else{
//$pagination.= "<li><a class='current'>Next</a></li>";
// $pagination.= "<li><a class='current'>Last</a></li>";
}
$pagination.= "</ul>\n";
}
return $pagination;
}
/****************************************////**pagination*****function*****************************************/
?>
<!---------------------------pagination------------------------------------------------->
<?php
//error_reporting(0);
$con = mysqli_connect("localhost","root","","accounts");
$page=1;//Default page
$limit=2;//Records per page
$start=0;//starts displaying records from 0
if(isset($_GET['page']) && $_GET['page']!=''){
$page=$_GET['page'];
}
$start=($page-1)*$limit;
?>
<!---------------------------pagination-------end------------------------------------------>
<table width="100%" >
<tr>
<td>
<?php
$query = mysqli_query($con,"select * from receipts");
$rows=mysqli_num_rows($query);
//newly registerd on top
$query=mysqli_query($con,"select * from receipts order by r_id ASC LIMIT $start, $limit");
if(mysqli_num_rows($query)>0){
while($row = mysqli_fetch_array($query,1)){
?>
<table cellpadding="3" cellspacing="3" border="1px #f8f8f8" width="100%" style="background-color:#FFFFFF;border:1px solid #e8e8e8">
<tr>
<td id="class1">Name</td>
<td id="class2"><?php echo $row['party_name'] ;?></td>
</tr>
<tr><td id="class1">Roll No</td>
<td width="700px" id="class2"><?php echo $row['receipt_no']; ?></td>
</tr>
<tr>
<td id="class1" width="170px">Date</td>
<td id="class2"><?php echo $row['date1']; ?></td>
</tr>
</table>
<?php
}}
?>
</td>
</tr>
</table>
<?php
if(empty($_GET['id']))
{
$id = 1;
}
if(isset($_GET['id'])){
$id = $_GET['id'];
}
echo '</table><table>';
echo "<tr><td>";
echo pagination($limit,$page,'try.php?id='.$id.'&page=',$rows); //call function to show pagination
echo "</td></tr>";
echo "</table>";
?>
</div>