今天寫(xiě)的分頁(yè)類......分享
Jun 21, 2016 am 09:11 AM分頁(yè)
由于是上班時(shí)候?qū)懙模匀绻坑刹抠N出來(lái)恐怕對(duì)不起公司,所以我把其中的表單跳轉(zhuǎn)刪去了。別見(jiàn)怪哦。。。
格式寫(xiě)法是比較標(biāo)準(zhǔn)的了
PHP代碼:--------------------------------------------------------------------------------
/**********
| +---------------------------------------------------
| CLASS NAME: PageBar
| +---------------------------------------------------
| Author: Arvan [E-mail:Arvan@5n9.com QQ:8817776]
| Create date: 2003-7-17
| Note:
| Do for pagination
| +---------------------------------------------------
| Warning: no...
| +---------------------------------------------------
**********/
class PageBar
{
var $total;
var $onepage;
var $num;
var $pagecount;
var $total_page;
var $offset;
var $linkhead;
function PageBar($total, $onepage, $form_vars='')
{
$pagecount = $_GET['pagecount'];
$this->total = $total;
$this->onepage = $onepage;
$this->total_page = ceil($total/$onepage);
if (empty($pagecount))
{
$this->pagecount = 1;
$this->offset = 0;
}
else
{
$this->pagecount = $pagecount;
$this->offset = ($pagecount-1)*$onepage;
}
if (!empty($form_vars))
{
$vars = explode("|", $form_vars);
$chk = $vars[0];
$chk_value = $_POST['$chk'];
if (empty($chk_value))
{
$formlink = "";
}
else
{
for ($i=0; $i
$var = $vars[$i];
$value = $_POST['$var'];
$addchar = $vars."=".$value;
$addstr = $addstr.$addchar."&";
}
$formlink = "&".substr($addstr, 0, sizeof($addstr)-1);
}
}
else
{
$formlink = "";
}
$linkarr = explode("pagecount=", $_SERVER['QUERY_STRING']);
$linkft = $linkarr[0];
if (empty($linkft))
{
$this->linkhead = $_SERVER['PHP_SELF']."?".$formlink;
}
else
{
$this->linkhead = $_SERVER['PHP_SELF']."?".$linkft.$formlink;
}
}
#End function PageBar();
function offset()
{
return $this->offset;
}
#End function offset();
function pre_page($char='')
{
$linkhead = $this->linkhead;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = "[ }
if ($pagecount>1)
{
$pre_page = $pagecount - 1;
return "$char";
}
else
{
return ' ';
}
}
#End function pre_page();
function next_page($char='')
{
$linkhead = $this->linkhead;
$total_page = $this->total_page;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = "[>]";
}
if ($pagecount {
$next_page = $pagecount + 1;
return "$char";
}
else
{
return ' ';
}
}
#End function next_page();
function num_bar($num='', $color='', $left='', $right='')
{
$num = (empty($num))?10:$num;
$this->num = $num;
$mid = floor($num/2);
$last = $num - 1;
$pagecount = $this->pagecount;
$totalpage = $this->total_page;
$linkhead = $this->linkhead;
$left = (empty($left))?"[":$left;
$right = (empty($right))?"]":$right;
$color = (empty($color))?"#ff0000":$color;
$minpage = (($pagecount-$mid)$pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage }
for ($i=$minpage; $i {
$char = $left.$i.$right;
if ($i==$pagecount)
{
$char = "$char";
}
$linkchar = "".$char."";
$linkbar = $linkbar.$linkchar;
}
return $linkbar;
}
#End function num_bar();
function pre_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$num = $this->num;
$mid = floor($num/2);
$minpage = (($pagecount-$mid)$pagecount-$mid);
$char = (empty($char))?"[ $pgpagecount = ($minpage>$num)?$minpage-$mid:1;
return "".$char."";
}
#End function pre_group();
function next_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$totalpage = $this->total_page;
$num = $this->num;
$mid = floor($num/2);
$last = $num;
$minpage = (($pagecount-$mid)$pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage }
$char = (empty($char))?"[>>]":$char;
$ngpagecount = ($totalpage>$maxpage+$last)?$maxpage + $mid:$totalpage;
return "".$char."";
}
#End function next_group();
function whole_num_bar($num='', $color='')
{
$num_bar = $this->num_bar($num, $color);
$pre_group = $this->pre_group();
$pre_page = $this->pre_page();
$next_page = $this->next_page();
$next_group = $this->next_group();
return $pre_group.$pre_page.$num_bar.$next_page.$next_group;
}
#End function whole_bar();
}
#End class PageBar;
/*****
//example
$total = 1000;
$onepage = 20;
$pb = new PageBar($total, $onepage);
$offset = $pb->offset();
$pagebar = $pb->whole_num_bar();
echo $offset."
".$pagebar;
return:
0
[][>>]
*****/

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出而不是在空白頁(yè)彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁(yè)彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

This article will help you interpret the vue source code and introduce why you can use this to access properties in various options in Vue2. I hope it will be helpful to everyone!

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

How to Optimize iPad Battery Life with iPadOS 17.4 Extending battery life is key to the mobile device experience, and the iPad is a good example. If you feel like your iPad's battery is draining too quickly, don't worry, there are a number of tricks and tweaks in iPadOS 17.4 that can significantly extend the run time of your device. The goal of this in-depth guide is not just to provide information, but to change the way you use your iPad, enhance your overall battery management, and ensure you can rely on your device for longer without having to charge it. By adopting the practices outlined here, you take a step toward more efficient and mindful use of technology that is tailored to your individual needs and usage patterns. Identify major energy consumers

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.
