清空数据表   truncate 表名;

http://blog.knowsky.com/234205.htm    常用的SQL语句实例

http://blog.csdn.net/vericlongmore/article/details/7431029   php mysql数据库常用sql语句命令集合

http://www.banghui.org/10064.html     PHP新手必学的常用SQL语句 数据库

http://blog.163.com/lgh_2002/blog/static/440175262007102511246481/    SQL语句大全

*替换数据库敏感词*

把"北京"替换成"南京'

update jinsha_category set catname=replace(catname,'北京','南京');

要求:

一个字段值:

………………预约…………

要将其中 “预约”,改成“预定”。

但是我开始写的时候,写成了

  1. update ..set smscontent = replace ('预约','预定')

1:连接数据库:

<?php
$conn = mysql_connect("localhost","root","www.xunjobs.com") or die("数据库连接失败".mysql_error());
mysql_select_db("db_pursey",$conn) or die("数据库访问失败".mysql_error());
mysql_query("set names gb2312");
?>

2:插入数据:

<?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");获得系统日期
$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中输出<script>语句的方法
echo "<script>alert('恭喜您,信息发布成功!');window.location.href='release.php';</script>";
}else{
echo "<script>alert('对不起,信息发布失败!');history.back();</script>";
}
?>

3:查询数据

<?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;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[edate]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[content]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[linkman]);?>&nbsp;&nbsp;&nbsp;联系电话:<?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;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[edate]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[content]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[linkman]);?>&nbsp;&nbsp;&nbsp;联系电话:<?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;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[edate]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[content]);?></td>
                    </tr>
                    <tr>
                      <td height="26">&nbsp;联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[linkman]);?>&nbsp;&nbsp;&nbsp;联系电话:<?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">您检索的信息资源不存在!</td>
                    </tr>
                  </table>
    <?php
     }
    }
      ?>

转自:http://blog.csdn.net/aerchi

php中一些常用的语句收集的更多相关文章

  1. Oracle系统表整理+常用SQL语句收集

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  2. awk在企业中最常用的语句

    awk最常用以及面试基本都会被问到的实例: A.统计日志中每个URL被访问的次数 cat access.log http://www.etiantian.org/1.html http://post. ...

  3. Oracle系统表整理+常用SQL语句收集(转载)

    原文:https://www.cnblogs.com/jiangxinnju/p/5840420.html-- DBA/ALL/USER/V_$/GV_$/SESSION/INDEX开头的绝大部分都是 ...

  4. sql 2008常用语法语句收集

    EXEC sp_dropuser 'test' : 从当前数据库删除用户 test EXEC sp_droplogin 'test' : 从 SQL Server 中删除登录 test select ...

  5. from selenium.webdriver.chrome.options import Options中add_argument 常用参数表收集

    chrome_options.add_argument("xxx") 序号 参数 说明 1 --allow-outdated-plugins 不停用过期的插件. 2 --allow ...

  6. MySQL 存储过程常用SQL语句收集

    1,select curdate() /*2016-10-08*/ 2,select date_sub(curdate(), INTERVAL 6 DAY) /*2016-10-02*/ 3,case ...

  7. ios中常见数据存储方式以及SQLite常用的语句

    在iOS中,根据不同的需求对应的有多种数据存储方式: 1.NSUserdefaults  将数据存储到沙盒中(library),方便易用,但是只能存储系统提供的数据类型(plist),不能存储自定义的 ...

  8. mysql中常用的语句整理

    mysql中常用的语句: 1:创建带自增长的主键的表 DROP TABLE IF EXISTS user_login ; CREATE TABLE user_login (   user_id INT ...

  9. Lua中的常用语句结构以及函数

     1.Lua中的常用语句结构介绍 --if 语句结构,如下实例: gTable = {} ] ] then ]) == gTable[] then ]) else print("unkown ...

随机推荐

  1. CCMotionStreak(一)

    void MotionStreakTest1::onEnter() { MotionStreakTest::onEnter(); CCSize s = CCDirector::sharedDirect ...

  2. angular学习笔记(五)-阶乘计算实例(2)

    <!DOCTYPE html> <html ng-app> <head> <title>2.3.3计算阶乘实例2</title> <m ...

  3. TOMCAT8源码分析——处理请求分析(下)

    前言 本文继续讲解TOMCAT的请求原理分析,建议朋友们阅读本文时首先阅读过<TOMCAT源码分析——请求原理分析(上)>和<TOMCAT源码分析——请求原理分析(中)>.在& ...

  4. Java调用存储过程小结

    学生在学习jdbc的时候,会问到怎么调用存储过程,现在将java调用oracle存储过程的示例总结如下.(关于调用sqlserver的存储过程将在下次进行小结请关注) 一:无返回值的存储过程 存储过程 ...

  5. MD5算法实现

    MD5算法的简要叙述为: MD5以512位分组来处理输入的信息(512位分组?每次处理都取出512位数据?), 每一分组又被划分为16个32位子分组(16乘32刚好是512), 经过一些列的处理后(怎 ...

  6. C语言 · 黑色星期五

    算法训练 黑色星期五   时间限制:1.0s   内存限制:512.0MB      问题描述 有些西方人比较迷信,如果某个月的13号正好是星期五,他们就会觉得不太吉利,用古人的说法,就是“诸事不宜” ...

  7. kubernetes service访问原理

    k8s集群中有三类IP: 1:宿主机的物理网卡IP,比如192.168.255.* 2:cni创建的网卡的IP,比如172.16.*.* 3:虚拟的IP(即ClusterIP ,无法ping通,通过代 ...

  8. SpringBoot配置成Liunx服务

    spring boot 可以打包成可执行的脚本来启动,其原理是在打成包时,将shell脚本注入到jar包中 #参考:https://docs.spring.io/spring-boot/docs/1. ...

  9. Yii-模型- criteria查找数据库方法

    数据模型搜索方法: public function search() { // Warning: Please modify the following code to remove attribut ...

  10. wso2as安装

    1.系统环境 Ubuntu12.04    192.168.0.97    root/password找管理员 Ubuntu12.04    192.168.0.99    root/password ...