Collect common statements in php

Source: Internet
Author: User
Tags php mysql
: This article mainly introduces some common statements in php. For more information about PHP tutorials, see. Clear the name of the truncate table;

Common SQL statement instances for http://blog.knowsky.com/234205.htm

Http://blog.csdn.net/vericlongmore/article/details/7431029 php mysql database common SQL statement command set

Http://www.banghui.org/10064.html PHP beginner must learn commonly used SQL statement database

Http://blog.163.com/lgh_2002/blog/static/440175262007102511246481/ SQL statement Daquan

1: connect to the database:

$ Conn = mysql_connect ("localhost", "root", "www.xunjobs.com") or die ("database connection failed". mysql_error ());
Mysql_select_db ("db_pursey", $ conn) or die ("database access failed". mysql_error ());
Mysql_query ("set names gb2312 ");
?>

2: insert data:

Include ("conn/conn. php ");
$ Type = $ _ POST [type];
$ Title = $ _ POST [title];
$ C/span>
$ Linkman = $ _ POST [linkman];
$ Tel = $ _ POST [tel];
// $ Edate = date ("Y-m-d h: I: s"); obtain the system date
$ Edate = date ("Y-m-d H: I: s ");
$ SQL = mysql_query ("insert into tb_info (type, title, content, linkman, tel, checkstate, edate) values ('$ type',' $ title ', '$ content',' $ linkman ',' $ tel ', 0,' $ edate ')");
If ($ SQL ){
// Php method for outputting the script statement
Echo "script" alert ('Congratulations, the message is published successfully! '); Window. location. href = 'release. php'; script ";
} Else {
Echo "script" alert ('sorry, the message failed to be published! '); History. back (); script ";
}
?>

3: query data

Include ("conn/conn. php ");
$ Type = $ _ POST [type];
$ C/span>
$ Sql1 = mysql_query ("select * from tb_leaguerinfo where checkstate = 1 and type = '$ type' and (content like' % $ content % 'or title like' % $ content %' or linkman like '% $ content %' or tel like '% $ content % ') ");
$ Info1 = mysql_fetch_array ($ sql1 );
$ SQL = mysql_query ("select * from tb_info where checkstate = 1 and type = '$ type' and (content like' % $ content % 'or title like' % $ content %' or linkman like '% $ content %' or tel like '% $ content % ') ");
$ Info = mysql_fetch_array ($ SQL );
?>
If ($ info1 ){
Do {
?>














『 』
Contact: Contact number:

} While ($ info1 = mysql_fetch_array ($ sql1 ));
?>





If ($ info ){
Do {
?>













『 』
Contact: Contact number:

} While ($ info = mysql_fetch_array ($ SQL ));
}
} Else {
?>
If ($ info ){
Do {
?>













『 』
Contact: Contact number:

} While ($ info = mysql_fetch_array ($ SQL ));
} Else {
?>




The information resource you Retrieved does not exist!

}
}
?>

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.