首頁 >後端開發 >php教程 >解析link_mysql的php版_PHP教程

解析link_mysql的php版_PHP教程

WBOY
WBOY原創
2016-07-21 15:01:22727瀏覽

复制代码 代码如下:

$str_sql_read="select count(*) as num from userinfo";
$str_sql_del="delete from userinfo where id =1";
$res =link_mysql("read",$str_sql_read);
$res_del =link_mysql("delete",$str_sql_del);
echo $res_del."
";
while($row = mysql_fetch_assoc($res))
{
 echo "".$row['num']."
";
}

?>

function link_mysql($opt,$str_sql)
{
 $con = mysql_connect("localhost","root","root") or die ('Not connected : ' . mysql_error());
 mysql_set_charset("gbk",$con);
 //if you donot know how to use this function,find it defination;
 mysql_select_db("website",$con);
 switch($opt){
  case "read":
   $res =mysql_query($str_sql);
  break; 
  case "update":
  case "delete":
  case "insert":
   $res =mysql_query($str_sql);
  break;   
 }
 mysql_close();
 return $res;
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327991.htmlTechArticle复制代码 代码如下: ?php $str_sql_read="select count(*) as num from userinfo"; $str_sql_del="delete from userinfo where id =1"; $res =link_mysql("read",$str_sql_read); $res_...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn