php中一些常用的語句收集

來源:互聯網
上載者:User
清空資料表 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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.