解析link_mysql的php版

复制代码 代码如下:
<?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_del =link_mysql("delete",$str_sql_del);
echo $res_del."<br/>";
while($row = mysql_fetch_assoc($res))
{
 echo "<font style='font-size:25px;color:red;'>".$row['num']."</font><br/>";
}

?>

<?php
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;
}
?>

php技术解析link_mysql的php版,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。