gpt4 book ai didi

php - 换页时可以发送数据吗[分页]

转载 作者:行者123 更新时间:2023-11-29 12:00:17 26 4
gpt4 key购买 nike

我想使用分页查看按用户输入的日期排序的数据。

这就是我的查询的样子:

$pages_query = mysql_query("SELECT COUNT(id), BuyerName,BuyerEmail,TransactionID,DateTime 
FROM `order` WHERE YEAR(DateTime)= $Year AND MONTH(DateTime) = $Month")
or die(mysql_error());

$query = mysql_query("SELECT id, BuyerName,BuyerEmail,TransactionID,DateTime
FROM `order` WHERE YEAR(DateTime)= $Year AND
MONTH(DateTime) = $Month LIMIT $start, $per_page")
or die(mysql_error());

当我单击下一页时,它显示错误。当我只运行没有 WHERE 的查询时,分页效果很好。任何如何解决这个问题的建议都会很棒。

这是整个分页代码:

<?php

include('../include/conn.php');
$button = $_GET ['submit'];
$Month = $_GET ['Month'];
$Year = $_GET ['Year'];
$per_page = 5;
$adjacents = 6;

$pages_query = mysql_query("SELECT COUNT(id), BuyerName,BuyerEmail,TransactionID,DateTime
FROM `order`")
or die(mysql_error());

//get total number of pages to be shown from total result
$pages = ceil(mysql_result($pages_query, 0) / $per_page);

//get current page from URL ,if not present set it to 1
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1 ;

//calcuproduct_namee actual start page with respect to Mysql
$start = ($page - 1) * $per_page;

//execute a mysql query to retrieve all result from current page by using LIMIT keyword in mysql
//if query fails stop further execution and show mysql error

$query = mysql_query("SELECT id, BuyerName,BuyerEmail,TransactionID,DateTime FROM `order`
WHERE YEAR(DateTime)= $Year AND MONTH(DateTime) = $Month LIMIT $start, $per_page")
or die(mysql_error());

$pagination="Pagination";
//if current page is first show first only else reduce 1 by current page
$Prev_Page = ($page==1)?1:$page - 1;

//if current page is last show last only else add 1 to current page
$Next_Page = ($page>=$pages)?$page:$page + 1;

//if we are not on first page show first link
if($page!=1) $pagination.= '<a href="?page=1">First</a>';
//if we are not on first page show previous link
if($page!=1) $pagination.='<a href="?page='.$Prev_Page.'">Previous</a>';

//we are going to display 5 links on pagination bar
$numberoflinks=5;

//find the number of links to show on right of current page
$upage=ceil(($page)/$numberoflinks)*$numberoflinks;
//find the number of links to show on left of current page
$lpage=floor(($page)/$numberoflinks)*$numberoflinks;
//if number of links on left of current page are zero we start from 1
$lpage=($lpage==0)?1:$lpage;
//find the number of links to show on right of current page and make sure it must be less than total number of pages
$upage=($lpage==$upage)?$upage+$numberoflinks:$upage;
if($upage>$pages)$upage=($pages-1);
//start building links from left to right of current page
for($x=$lpage; $x<=$upage; $x++){
//if current building link is current page we don't show link,we show as text else we show as linkn
$pagination.=($x == $page) ? ' <strong>'.$x.'</strong>' : ' <a href="?page='.$x.'">'.$x.'</a>' ;
}
//we show next link and last link if user doesn't on last page
if($page!=$pages) $pagination.= ' <a href="?page='.$Next_Page.'">Next</a>';
if($page!=$pages) $pagination.= ' <a href="?page='.$pages.'">Last</a>';


?>

当我点击下一步按钮时,它无法获取 $Month$Year

如何将数据发送到搜索的第 2 页?

最佳答案

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com