Collection of common statements in php and collection of common php statements
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:
<? Php
$ 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:
<? Php
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 ){
// Method for outputting the <script> statement in php
Echo "<script> alert ('Congratulations, the message is published successfully! '); Window. location. href = 'release. php'; </script> ";
} Else {
Echo "<script> alert ('Sorry, message publishing failed! '); History. back (); </script> ";
}
?>
3: query data
<? Php
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 );
?>
<? Php
If ($ info1 ){
Do {
?>
<Table width = "540" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td height = "26"> '<? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [type]);?> 』 & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [title]);?> & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [edate]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [content]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; contact: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [linkman]);?> & Nbsp; contact number: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info1 [tel]);?> </Td>
</Tr>
<Tr>
<Td height = "3" background = "Images/line1.gif"> </td>
</Tr>
</Table>
<? Php
} While ($ info1 = mysql_fetch_array ($ sql1 ));
?>
</Td>
</Tr>
<Tr>
<Td height = "140" align = "center" valign = "top"> <br>
<? Php
If ($ info ){
Do {
?>
<Table width = "540" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td height = "26"> '<? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [type]);?> 』 & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [title]);?> & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [edate]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [content]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; contact: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [linkman]);?> & Nbsp; contact number: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [tel]);?> </Td>
</Tr>
<Tr>
<Td height = "3" background = "Images/line1.gif"> </td>
</Tr>
</Table>
<? Php
} While ($ info = mysql_fetch_array ($ SQL ));
}
} Else {
?>
<? Php
If ($ info ){
Do {
?>
<Table width = "540" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td height = "26"> '<? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [type]);?> 』 & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [title]);?> & Nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [edate]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [content]);?> </Td>
</Tr>
<Tr>
<Td height = "26"> & nbsp; contact: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [linkman]);?> & Nbsp; contact number: <? Php echo str_ireplace ($ content, "<font color = '# FF0000'>". $ content. "</font>", $ info [tel]);?> </Td>
</Tr>
<Tr>
<Td height = "3" background = "Images/line1.gif"> </td>
</Tr>
</Table>
<? Php
} While ($ info = mysql_fetch_array ($ SQL ));
} Else {
?>
<Table width = "540" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td align = "center"> the information resource you retrieved does not exist! </Td>
</Tr>
</Table>
<? Php
}
}
?>