Collect common statements in php

Source: Internet
Author: User
Tags php mysql
Required for beginners of PHP

Some common statements in php collection clear data table truncate table name; http://blog.knowsky.com/234205.htm commonly used SQL statement instance http://blog.csdn.net/vericlongmore/article/details/7431029 php mysql database commonly used SQL statement command set http://www.banghui.org/10064.html PHP beginner must

Collect common statements in php

Clear the name of the truncate table;

Http://blog.knowsky.com/234205.htmCommon SQL statement instances

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

Http://www.banghui.org/10064.htmlCommon SQL statement databases required for beginners of PHP

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

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];
$ Content = $ _ POST [content];
$ 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];
$ Content = $ _ POST [content];
$ 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.