Php database content search (search for specified content and output) _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.