清空資料表 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語句大全
1:串連資料庫:
$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:插入資料:
include("conn/conn.php");
$type=$_POST[type];
$title=$_POST[title];
$c/span>
$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中輸出";
}else{
echo "";
}
?>
3:查詢資料
include("conn/conn.php");
$type=$_POST[type];
$c/span>
$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{
?>
}while($info1=mysql_fetch_array($sql1));
?>
if($info){
do{
?>
} while($info=mysql_fetch_array($sql));
}
}else{
?>
if($info){
do{
?>
} while($info=mysql_fetch_array($sql));
}else{
?>
}
}
?>
轉自:http://blog.csdn.net/aerchi
以上就介紹了php中一些常用的語句收集,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。