There is a data table that contains multiple fields. On the page, select a field type from the drop-down menu, click query in a text box (enter a keyword in it), and display the query results on pages. How can this problem be achieved?
For example, my data table contains "document name", "document number", and "document remarks". First, I select "document remarks" on the query type, and then enter a keyword in the text box to click "query ". the results are displayed on pages, it is very urgent to ask PHP experts to help with graduation design. Thank you!
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
<Body>
<! -- Start by page -->
<? PHP
If (isset ($ _ Get ['page']) // obtain the parameters of the current page number through the get method.
{
$ Page = $ _ Get ['page'];
}
Else
{
$ Page = 1;
}
$ Page_size = 2; // two data entries are displayed on each page.
// Obtain the total amount of data
$ Db_host = 'localhost'; // Database Host
$ Db_user = 'tianchunlil'; // Database User Account
$ Db_passw = '000000'; // database account password
$ Db_name = 'aoyou'; // Database Name
// Connect to the database
$ Conn = mysql_connect ($ db_host, $ db_user, $ db_passw) or die ("database connection failed! ");
// Set the character set, such as utf8 and GBK, depending on the character set of the database
Mysql_query ("set names gb2312 ");
// Select a database
Mysql_select_db ($ db_name, $ conn) or die ('database selection failed! ');
$ Xuesheng_xm =$ _ post [xuesheng_xm]; // name
$ Xuesheng_xb =$ _ post [xuesheng_xb]; // gender
$ Xuesheng_sg1 =$ _ post [xuesheng_sg1]; // The minimum height
$ Xuesheng_sg2 =$ _ post [xuesheng_sg2]; // corresponds to the highest height.
$ SQL = "select * From biao1 where 1 = 1 ";
If ($ xuesheng_xm! = ''){
$ SQL. = "and xuesheng_xm like '% $ xuesheng_xm % '";
}
If ($ xuesheng_xb! = ''){
$ SQL. = "and xuesheng_xb = $ xuesheng_xb ";
}
If ($ xuesheng_sg1! =-1 & $ xuesheng_sg2! =-1 ){
$ SQL. = "and xuesheng_sg between $ xuesheng_sg1 and $ xuesheng_sg2 ";
}
$ Result = mysql_query ($ SQL );
$ Total = mysql_num_rows ($ result );
$ Start = ($ page-1) * $ pagesize;
$ Result = mysql_query ($ SQL );
// Echo $ total;
// Start to calculate the total number of pages
If ($ total)
{
If ($ total <$ page_size)
$ Page_count = 1;
If ($ Total % $ page_size)
{
$ Page_count = (INT) ($ total/$ page_size) + 1;
}
Else
{
$ Page_count = $ total/$ page_size;
}
}
Else
{
$ Page_count = 0;
}
// Flip Link
$ Turn_page = '';
If ($ page = 1)
{
$ Turn_page. = 'homepage | Previous Page | ';
}
Else
{
$ Turn_page. = '<a href = 2.php? Page = 1> homepage </a> | <a href = 2.php? Page = '. ($ page-1).'> previous page </a> | ';
}
If ($ page = $ page_count | $ page_count = 0)
{
$ Turn_page. = 'Next page | last page ';
}
Else
{
$ Turn_page. = '<a href = 2.php? Page = '. ($ page + 1).'> next page </a> | <a href = 2.php? Page = '. $ page_count.'> last page </a> ';
}
$ SQL = $ SQL. "limit". ($ page-1) * $ page_size. ",". $ page_size;
Echo $ SQL;
$ Result = mysql_query ($ SQL );
?>
<? PHP
While ($ ROW = mysql_fetch_array ($ result ))
{
Echo $ row ['xuesheng _ XM '];
}
?>
<Br/>
<? PHP echo $ turn_page?>
</Body>
</Html>
In this case, modify the data query statement based on your own needs! I use my own database