php中一些常用的语句收集
清空数据表 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,'北京','南京');
要求:
一个字段值:
………………预约…………
要将其中 “预约”,改成“预定”。
但是我开始写的时候,写成了
- 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]);?>』 <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[title]);?> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[edate]);?></td>
</tr>
<tr>
<td height="26"> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[content]);?></td>
</tr>
<tr>
<td height="26"> 联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info1[linkman]);?> 联系电话:<?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]);?>』 <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[title]);?> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[edate]);?></td>
</tr>
<tr>
<td height="26"> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[content]);?></td>
</tr>
<tr>
<td height="26"> 联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[linkman]);?> 联系电话:<?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]);?>』 <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[title]);?> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[edate]);?></td>
</tr>
<tr>
<td height="26"> <?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[content]);?></td>
</tr>
<tr>
<td height="26"> 联系人:<?php echo str_ireplace($content,"<font color='#FF0000'>".$content."</font>",$info[linkman]);?> 联系电话:<?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中一些常用的语句收集的更多相关文章
- Oracle系统表整理+常用SQL语句收集
欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...
- awk在企业中最常用的语句
awk最常用以及面试基本都会被问到的实例: A.统计日志中每个URL被访问的次数 cat access.log http://www.etiantian.org/1.html http://post. ...
- Oracle系统表整理+常用SQL语句收集(转载)
原文:https://www.cnblogs.com/jiangxinnju/p/5840420.html-- DBA/ALL/USER/V_$/GV_$/SESSION/INDEX开头的绝大部分都是 ...
- sql 2008常用语法语句收集
EXEC sp_dropuser 'test' : 从当前数据库删除用户 test EXEC sp_droplogin 'test' : 从 SQL Server 中删除登录 test select ...
- from selenium.webdriver.chrome.options import Options中add_argument 常用参数表收集
chrome_options.add_argument("xxx") 序号 参数 说明 1 --allow-outdated-plugins 不停用过期的插件. 2 --allow ...
- MySQL 存储过程常用SQL语句收集
1,select curdate() /*2016-10-08*/ 2,select date_sub(curdate(), INTERVAL 6 DAY) /*2016-10-02*/ 3,case ...
- ios中常见数据存储方式以及SQLite常用的语句
在iOS中,根据不同的需求对应的有多种数据存储方式: 1.NSUserdefaults 将数据存储到沙盒中(library),方便易用,但是只能存储系统提供的数据类型(plist),不能存储自定义的 ...
- mysql中常用的语句整理
mysql中常用的语句: 1:创建带自增长的主键的表 DROP TABLE IF EXISTS user_login ; CREATE TABLE user_login ( user_id INT ...
- Lua中的常用语句结构以及函数
1.Lua中的常用语句结构介绍 --if 语句结构,如下实例: gTable = {} ] ] then ]) == gTable[] then ]) else print("unkown ...
随机推荐
- cocos2d-x画线
在class HelloWorld : public cocos2d::CCLayer中添加 void draw(); 实现: void HelloWorld::draw() { CCSize s = ...
- 公共的Json操作C#类
using System; using System.Data; using System.Text; using System.Collections.Generic; using System.R ...
- Linux写时拷贝技术(copy-on-write)
1.传统的fork()函数创建一个子进程,子进程和父进程共享正文段,复制数据段,堆,栈到子进程示意图如下: 2.Linux的fork()函数-写时复制(copy-on-write)创建一个子进程,内核 ...
- python常用的十进制、16进制、字符串、字节串之间的转换
进行协议解析时,总是会遇到各种各样的数据转换的问题,从二进制到十进制,从字节串到整数等等 废话不多上,直接上例子 整数之间的进制转换: 10进制转16进制: hex(16) ==> 0x10 ...
- 請問 localtime() 為什麼不會造成 memory leak?
http://www.programmer-club.com.tw/ShowSameTitleN/vc/22380.html ************************************* ...
- js在一个可编辑的div光标处插入图片或者文本(兼容ie,火狐等浏览器)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- LeetCode: Wildcard Matching 解题报告
Wildcard MatchingImplement wildcard pattern matching with support for '?' and '*'. '?' Matches any s ...
- PHP中Array的hash函数实现
PHP中使用最多的非Array莫属了,那Array是如何实现的? 在PHP内部Array通过一个hashtable来实现,其中使用链接法解决hash冲突的问题,这样最坏情况下,查找Array元素的复杂 ...
- [shell]shell脚本统计数值大小
#! /bin/bash array=( ... ) var1= var2= ;i<=;i++)); do array[i]="$( cat /sys/bus/iio/devices/ ...
- Extjs 继承Ext.Component自定义组件
//自定义HTML组件 Ext.define('MyCmp', { extend: 'Ext.Component', renderTpl: [ '<h1 class="title&qu ...