<HTML>
<Body>
<Form action = "new_delete.php" method = "Post">
<Table border = 2 align = "center">
<? PHP
Include 'conn. php ';
$ SQL = "select * From table_for_page ";
$ Result = mysql_query ($ SQL );
$ Number = mysql_num_rows ($ result); // The total number of records.
$ Pagesize = 10; // number of entries displayed per page
If (! Isset ($ _ Get ['page'])
{
$ Page = 1; // determine whether it is the first page
}
Else
{
$ Page = (INT) ($ _ Get ['page']); // obtain the page number.
}
If ($ Number % $ pagesize = 0)
{
$ Total = (INT) ($ number/$ pagesize );
}
Else
{
$ Total = (INT) ($ number/$ pagesize) + 1;
}
$ Start = ($ page-1) * $ pagesize;
$ SQL = "select * From table_for_page limit $ start, $ pagesize ";
$ Result = mysql_query ($ SQL );
$ ROW = mysql_fetch_row ($ result );
While ($ row)
{
?> <Tr>
<? PHP
For ($ I = 0; $ I <3; $ I ++)
{
If ($ I = 0)
Echo "<TD> <input type = \" checkbox \ "name = \" check [] \ "value = $ row [0]> </TD> ";
Echo "<TD> $ row [$ I] </TD> ";
}
Echo "<TD> <a href = \" new_delete.php? Id = $ row [0] & page = $ Page \ "> Delete </a> </TD> ";
$ ROW = mysql_fetch_row ($ result );
?>
</Tr>
<? PHP
}
?>
<Tr> <TD align = "center" colspan = "9">
<? PHP
If ($ page> 1)
{
$ Prev = $ page-1;
Echo "<a href = \" page2.php? Page = $ Prev \ "> $ Prev </a> ";
Echo "| ";
}
Echo $ page;
If ($ page <$ total)
{
$ Next = $ page + 1;
Echo "<a href = \" page2.php? Page = $ next \ "> $ next </a> ";
}
?>
</TD> </tr>
</Table>
<Table align = "center">
<Tr>
<TD> <input type = "hidden" name = "page" value = "<? PHP echo $ page;?> "> </TD>
</Tr>
<Tr>
<TD> <input type = "Submit" name = "Submit" value = "Submit"> </TD>
</Tr>
</Table>
</Form>
</Body>
</Html>
<? PHP
/*
* Summary of minor errors:
* 1: <form action = "new_delete.php" method = "Post"> <! -- Only form can be submitted, and table cannot be submitted -->
* 2: mysql_select_db ("ABC", $ conn); // quotation marks are still required for ABC.
* 3: $ result = mysql_query ($ SQL)
* 4: If (isset ($ _ Get ['id']), the hyperlink can only be obtained by get.
* 5: the submission of checkbox and so on depends on the method setting of the form.
* 6: $ SQL = "delete from table_for_page where id = $ id1"; // The $ id1, dollar sign worth noting when referencing variables in Khan PHP !!!
*/
?>