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! |
}
}
?>