PHP Page-Splitting

Source: Internet
Author: User
Tags foreach array exit count include sql query return
Today, after work to write a section of PHP page processing script, welcome to PAT Brick!!! Display Page index.php
 
  

Pagination processing function showbbsprocess.php
 -->
 
  
 ';
		If you iterate through the elements in the $arr array, that is, $i ($i starting from 0) equals the number of elements in the array minus one, jump out of the 2-tier loop (for Loop and foreach Loop) if ($i = = (count ($arr)-1)) Break 2; }} $RowCount =getrowcount ($connectmysql);//Total number of records $PageCount =ceil ($RowCount/$PageSize), and/or a few pages, ceil () function into a rounding Ech O ' Post statistics: '. $RowCount. ' '.'
	
	A total of '. $PageCount. ' Page ';
	When the first page is not output "previous page" if ($CurrentPageID!= 1) {echo "prev";
	//Forward page if ($CurrentPageID > 2) {echo "<<<";
	//Output detailed number of pages, such as: "1" for ($j =1; $j <= $PageCount; $j + +) {echo "[$j]";
	///Backward-skip if ($CurrentPageID <= ($PageCount-2)) {echo ">>>";
	///When the last page does not output "next page" if ($CurrentPageID!= $PageCount) {echo "next page";
} $connectmysql->closeconn (); }

function showbbs_fun.php of communication with database
 
  Getrowsarray ($sql);
	return $arr 1;
}

The function is used to query the rows of the tables of the database function
GetRowCount ($connectmysql) {
	$sql = "SELECT * from Db_content";
	$num = $connectmysql->getrowsnum ($sql);
	return $num;
}

Database Class connectmysql.php
 -->Conn=mysql_connect ($this->host, $this->username, $this->password);
		@mysql_select_db ($this->dbname, $this->conn);
	mysql_query (' Set names Utf-8 ');
		}//Query result function GetResult ($sql) {if ($this->conn== ') {$this->conndb ();
	$this->result=mysql_query ($sql, $this->conn);
		//Returns the number of records of the query function Getrowsnum ($sql) {$this->getresult ($sql);
		$num _rows=mysql_num_rows ($this->result);
		if (Mysql_errno () ==0) {return $num _rows;
		}else {return ";
		}///Output The result as a single array of records and return function GetArray ($sql) {$this->getresult ($sql); if (Mysql_errno () ==0) {$this->resultarray=mysql_fetch_array ($this-&GT;RESULT,MYSQL_ASSOC);//Get associative array return $
		this->resultarray;
		}else {return ";
		}//Returns a two-dimensional array function Getrowsarray ($sql) {$this->getresult ($sql) containing multiple records;
			if (Mysql_errno () ==0) {while ($row =mysql_fetch_array ($this->result,mysql_assoc)) {$this->rowsarray[]= $row;
			return $this->rowsarray; PriNt_r ($this->rowsarray); exit;
		}else {return ";
		}//update, add, remove function Uidresult ($sql) {if ($this->conn== ') {$this->conndb ();
		}//echo $sql;
		Exit
		@mysql_query ($sql);
		$this->rowsnum= @mysql_affected_rows ();
		if (Mysql_errno () ==0) {return $this->rowsnum;
		}else {return ";
		}//Release result set function Freeresult () {mysql_free_result ($this->result);
		$this->rowsnum=0;
		$this->rowsarray= ';
	$this->resultarray= ';
		///Close Database function Closeconn () {$this->freeresult ();
		Mysql_close ($this->conn);
	$this->conn= '; }
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.