解析link_mysql的php版

前端之家收集整理的这篇文章主要介绍了解析link_mysql的php版前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码如下:@H_301_2@
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."
";
while($row = MysqL_fetch_assoc($res))
{
echo "".$row['num']."
";
}

?>

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;
}
?>@H_301_2@

原文链接:https://www.f2er.com/php/25925.html

猜你在找的PHP相关文章