China Welfare Lottery 15 Pick 5 Lottery Results PHP result set paging implementation code

WBOY
Release: 2016-07-29 08:39:29
Original
2640 people have browsed it

Copy the code The code is as follows:


@mysql_connect("localhost", "root","1981427") //Connect to the database server
or die("Database server connection failed");
@mysql_select_db("test") //Select the database mydb
or die("The database does not exist or is unavailable");
$query = @mysql_query("select * from tablename1") //Execute the process for calculating the number of pages SQL statement
or die("SQL statement execution failed");
$pagesize = 5; //Set the number of records per page
$sum = mysql_numrows($query); //Calculate the total number of records
if($sum % $ pagesize == 0) //Calculate the total number of pages
$total = (int)($sum/$pagesize);
else
$total = (int)($sum/$pagesize) + 1;
if (isset( $_GET['page'])) //Get the page number
{
$p = (int)$_GET['page'];
}
else
{
$p = 1;
}
$start = $pagesize * ($p - 1); //Calculate the starting record
//Execute the SQL statement to query the current page record
$query = @mysql_query("select * from tablename1 limit $start, $pagesize")
or die(" SQL statement execution failed");
echo "

"; //Output table header
//Output all records from row 0 to the largest row in a loop
while($row = mysql_fetch_array ($query))
{
$serial_no = $row['id']; //Output the serial_no column of row $i
$name = $row['username']; //Output the name of row $i Column
$salary = $row['password']; //Output the salary column of row $i
echo "";
echo "";
echo "
echo ""; /Output the end of the table
if($p > 1) //When the current page is not the first page, output the link to the previous page
{
$prev = $p - 1;
echo "Previous page ";
}
if($p < $total) //When the current page is not the last page, output the following Link to one page
{
$next = $p + 1;
echo "Next page" ;
}
?>


The above introduces the paging implementation code of China Welfare Lottery 15-choice 5 lottery results PHP result set, including the content of China Welfare Lottery 15-choice 5 lottery results. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
$serial_no$salary