>  기사  >  백엔드 개발  >  解析link_mysql的php版_PHP教程

解析link_mysql的php版_PHP教程

WBOY
WBOY원래의
2016-07-21 15:01:22695검색

复制代码 代码如下:

$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으로 문의하세요.