php 鏁扮粍瀹炵幇鍒嗛〉
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 鏁扮粍瀹炵幇鍒嗛〉相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/ceil' title='ceil'>ceil content stat date ota 鍏ㄥ眬鍙橀噺 begin order
//涓€鍛ㄤ箣鍐呰幏鍙栫殑鏃堕棿鑼冨洿
銆€銆€銆€銆€銆€銆€$now_time = time(); $total_week =isset($_REQUEST[鈥榯otal_week鈥榏) && ($_REQUEST[鈥榯otal_week鈥榏 > 0) ? $_REQUEST[鈥榯otal_week鈥榏 : 1; $begin = $now_time - $total_week * 7 * 86400; $statDate = date("Y/m/d", $begin); $end = $now_time -($total_week - 1) * 7 * 86400; $endDate = date("Y/m/d", $end); $pageno = isset($_REQUEST[鈥榩ageno鈥榏) && ($_REQUEST[鈥榩ageno鈥榏 > 0) ? $_REQUEST[鈥榩ageno鈥榏 : 1; $pagesize = 10;
銆€銆€椤甸潰鍒锋柊鍒嗛〉
//鏄惁宸茬粡閲囬泦瀹? if ($pageno < $page_total) echo 鈥?lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />鈥? echo 鈥樺綋鍓嶇鈥?$total_week.鈥樺懆锛岀鈥?$pageno.鈥橀〉锛屽叡鈥?$page_total.鈥橀〉鈥? echo 鈥?lt;script>self.location="?total_week=鈥?$total_week.鈥?amp;pageno=鈥?($pageno + 1).鈥?;</script>鈥? exit; else if ($total_week > 1) $next_week = $total_week - 1; else echo 鈥?lt;script>self.location="xinshengbl.php";</script>鈥? echo 鈥榦k鈥? echo 鈥?lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />鈥? echo 鈥樺綋鍓嶇鈥?$total_week.鈥樺懆锛岀鈥?$pageno.鈥橀〉锛屽叡鈥?$page_total.鈥橀〉鈥? echo 鈥?lt;script>self.location="?total_week=鈥?$next_week.鈥?amp;pageno=1";</script>;鈥? exit;
return $this->page_array($pagesize,$pageno,$result[鈥榞oods_list鈥榏,0);
銆€銆€鏁扮粍鍒嗛〉鍑芥暟
/** * 鏁扮粍鍒嗛〉鍑芥暟 鏍稿績鍑芥暟 array_slice * 鐢ㄦ鍑芥暟涔嬪墠瑕佸厛灏嗘暟鎹簱閲岄潰鐨勬墍鏈夋暟鎹寜涓€瀹氱殑椤哄簭鏌ヨ鍑烘潵瀛樺叆鏁扮粍涓? * $count 姣忛〉澶氬皯鏉℃暟鎹? * $page 褰撳墠绗嚑椤? * $array 鏌ヨ鍑烘潵鐨勬墍鏈夋暟缁? * order 0 - 涓嶅彉 1- 鍙嶅簭 */ public function page_array($count,$page,$array,$order) global $countpage; #瀹氬叏灞€鍙橀噺 $page=(empty($page))?鈥?鈥?$page; #鍒ゆ柇褰撳墠椤甸潰鏄惁涓虹┖ 濡傛灉涓虹┖灏辫〃绀轰负绗竴椤甸潰 $start=($page-1)*$count; #璁$畻姣忔鍒嗛〉鐨勫紑濮嬩綅缃? if($order==1) $array=array_reverse($array); $totals=count($array); $countpage=ceil($totals/$count); #璁$畻鎬婚〉闈㈡暟 $pagedata=array(); $pagedata=array_slice($array,$start,$count); return $pagedata; #杩斿洖鏌ヨ鏁版嵁
銆€銆€
以上是关于php 鏁扮粍瀹炵幇鍒嗛〉的主要内容,如果未能解决你的问题,请参考以下文章