Php database content search (search for specified content and output ). The implementation principle is very simple. it is based on the data submitted by the user to the mysql data table to check whether there are the same, if there is no output, no operation will be performed. This is a simple record search code. The p implementation principle is very simple. it is based on the data submitted by the user to the mysql data table to query whether there is the same, if there is no output, no operation will be performed. This is a simple record search code.
Php Tutorial database tutorial content search (search for specified content and output)
/*
First, create a search data table.
Create table if not exists 'search '(
'Id' int (4) not null auto_increment,
'Keyword' varchar (500) not null,
Primary key ('id ')
) Engine = myisam default charset = utf8 auto_increment = 1;
Save data
Insert into 'ACC '. 'search '(
'Id ',
'Keyword'
)
Values (
Null, 'content search'
),(
Null, 'php intra-site search'
);
*/
// Data connection
$ Conn = mysql tutorial _ connect ('localhost', 'AC', '1'); // The ac user name here. 1 is the password and can be changed to your own mysql.
$ Res = mysql_db_query ('ABC', "select * from search where keyword = 'content search'") or die (mysql_error ());
If (mysql_num_rows ($ res) = 1 ){
While ($ row = mysql_fetch_assoc ($ res )){
Foreach ($ row as $ key => $ val ){
Echo $ row ['keyword'],'
';
}
}
}
/*
The implementation principle is very simple. it is based on the data submitted by the user to the mysql data table to check whether there are the same, if there is no output, no operation will be performed. This is a simple record search code.
SOURCE www. bKjia. c0m
*/
Bytes. This is a simple record search code. P...