資源描述:
《mysql增刪改查基本語句》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、mysql增、刪、改、查基本語句數(shù)據(jù)庫的鏈接和選擇及編碼$link=mysql_connect("localhost","root","123456")ordie("數(shù)據(jù)庫連接失敗".mysql_error());$sel=mysql_select_db("login",$link)ordie("數(shù)據(jù)庫選擇失敗".mysql_error());mysql_query("setnames'utf8'");添加數(shù)據(jù)$link=mysql_connect("localhost","root","123456")ordie("數(shù)
2、據(jù)庫連接失敗".mysql_error());$sel=mysql_select_db("login",$link)ordie("數(shù)據(jù)庫選擇失敗".mysql_error());mysql_query("setnames'utf8'",$sel);$add="insertintotitle(title,content,username,time)values('$title','$content','$username',$time)";$query=mysql_query($add);if($query){echo"a
3、ddsucess";echo"";}elseecho"addfalse";刪除數(shù)據(jù)$link=mysql_connect("localhost","root","123456")ordie("數(shù)據(jù)庫連接失敗".mysql_error());$sel=mysql_select_db("login",$link)ordie("數(shù)據(jù)庫選擇失敗".mysql_error());mysql_query("s
4、etnames'utf8'");$id=$_GET['id'];$delete="deletefromtitlewhereid='$id'";$query=mysql_query($delete);if($query){echo"deletesucess!";echo"";}elseecho"deletefalse";改數(shù)據(jù)$link=mysql_connect("localhost","root
5、","123456")ordie("數(shù)據(jù)庫連接失敗".mysql_error());$sel=mysql_select_db("login",$link)ordie("數(shù)據(jù)庫選擇失敗".mysql_error());mysql_query("setnames'utf8'",$sel);$update="updatetitlesettitle='".$title."',content='".$content."'whereid='$id'";$query=mysql_query($update);if($query){ec
6、ho"resetsucess!";echo"";}elseecho"resetfalse";查數(shù)據(jù)$link=mysql_connect("localhost","root","123456")ordie("數(shù)據(jù)庫連接失敗".mysql_error());$sel=mysql_select_db("login",$link)ordie("數(shù)據(jù)庫選擇失敗".mysql_error());mysql_
7、query("setnames'utf8'",$sel);$sql="select*fromtitle";$result=mysql_query($sql);while($rel=mysql_fetch_object($result)){?>
title;?> | id;?>">reset 8、9、l->id;?>">delete |
1.select查詢語句和條件語句select查詢字段from表名where條件查詢字段:可以使用通配符*、字段名、字段別名(字段名as..)表名:數(shù)據(jù)庫.表名,表名常用條件:=等于、<>不等于、in(值,值)包含、notin(值,值)不包含