PHP and MySQL questions about paging
Use PHP to extract the information from MySQL and show him the page
Code:
$mylink =mysql_connect ("localhost", "root", "998121021");mysql_select_db ("Liuyan", $mylink);$sql = "SELECT * from Data order by time";$result =mysql_query ($sql);$message _count=mysql_num_rows ($result);echo $message _count;$i = $message _count-1;$page _size=2;$page _count=ceil ($message _count/$page _size);echo $page _count;if ($page <1) $page = 1;if ($page > $page _count) $page = $page _count;$offset = ($page-1) * $page _size;$sql 1= "SELECT * from the data order by time limit $offset, $page _size";$result 1=mysql_query ($sql 1);while ($myarray =mysql_fetch_array ($result 1)) {Extract ($myarray);Echo '
'; Echo '
'. ($message _count-$i). " Building ". | '; Echo '
'." User name: ". $name. ' | '; Echo '
'.''. $email. ' | '; Echo '
'; Echo '
'; Echo '
'. $time. ' | '; Echo '
'; Echo '
'. $words. ' | '; Echo '
'; Echo '
'; Echo '
'.' '.' | '; Echo '
'; $i--;}? >
$pre _page= $page-1;
$next _page= $page +1;
Echo $page;
$PATH _info=pathinfo ("http://localhost:250/myphp Programming/Message Board page Display/message board pagination display. php");
if ($page ==1)
{
echo "first page previous page". " ";
}
Else
{
echo "First page";
echo "";
echo "Prev";
}
echo "";
if ($page = = $page _count)
{
echo "Next page last page";
}
Else
{
echo "Next page";
echo "";
echo "last Page";
echo $page _count;
}
?>
The pagination display part of the code is wrong, the path_info () function in the book is wrong, I do not know how to use, "http://localhost:250/myphp Programming/Message Board page Display/message board pagination display." PHP is my file path. In the "next page" "Last Page", "first page" "Previous page" link is how to write?
------Solution--------------------
$page =$_get[' page '? $_get[' page ': 1; Add this sentence.