Login   Register  
PHP Classes
elePHPant
Icontem

File: page.class.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Haibo Lin  >  Fast Split MySQL Result  >  page.class.js  >  Download  
File: page.class.js
Role: Auxiliary data
Content type: text/plain
Description: JS Code
Class: Fast Split MySQL Result
Display MySQL query results split in pages
Author: By
Last change:
Date: 2004-06-25 02:18
Size: 1,846 bytes
 

Contents

Class file image Download
var prvPage		=(page_offset==0)?1:page-1;
var nxtPage		=(page_offset + page_count >= totalrecord)?page:page+1;
var TotalPage	=Math.ceil(totalrecord/page_count);
TotalPage	=(TotalPage==0)?1:TotalPage;
var pageHTML="";
pageBase="<font style='font-size:9pt'>Total Record:<font color='#ff0000'>"+totalrecord+"</font>&nbsp;&nbsp;Pages:"+TotalPage+" &nbsp;&nbsp;";
if(TotalPage==1 || page==1)
	pageHTML+="<font style='font-size:9pt' disabled>First</font>&nbsp;";
else
	pageHTML+="<a href='"+theLink+"&page=1'>First</a>&nbsp;";
if(prvPage==page)
	pageHTML+="<font style='font-family:Webdings;font-size:14px;' disabled>3</font>&nbsp;";
else
	pageHTML+="<a title='Prv' style='font-family:Webdings;font-size:14px;' href='"+theLink+"&page="+prvPage+"'>3</a>&nbsp;";
if(TotalPage<=10)
{
	var offset_left=1;
	var offset_right=TotalPage; 
}
else 
{
	if(page-5<1)
	{
		var offset_left=1;
		var offset_right=10; 
	}
	else
	{ 
		if(page+4>TotalPage)
		{
			var offset_left=TotalPage-9;
			var offset_right=TotalPage; 	
		}
		else
		{
			var offset_left=page-5;
			var offset_right=page+4; 	
		}
	}
}
for(var i=offset_left;i<=offset_right;i++)
{
	if(page==i) 
		pageHTML+="<strong style='color:red'>"+i+"</strong>&nbsp;";
	else
		pageHTML+="<a href='"+theLink+"&page="+i+"'>"+i+"</a>&nbsp;";
}
if(nxtPage==page)
	pageHTML+="<font style='font-family:Webdings;font-size:14px;' disabled>4</font>&nbsp;";
else
	pageHTML+="<a title='Next' style='font-family:Webdings;font-size:14px;' href='"+theLink+"&page="+nxtPage+"'>4</a>&nbsp;";
if(TotalPage==page || TotalPage==1)
	pageHTML+="<font style='font-size:9pt' disabled>End</font>";
else
	pageHTML+="<a href='"+theLink+"&page="+TotalPage+"'>End</a>";
if(document.all("PageTop"))
{
	document.all("PageTop").innerHTML=pageHTML;
}
document.write(pageBase+pageHTML);