电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

解析link


发布日期:2019/7/30
 
本篇文章是对link_mysql的php版的实现进行了详细的分析介绍需要的朋友参考下复制代码 代码如下:
<?php
$str_sql_read="select count(*) as num from userinfo";
$str_sql_del="delete from userinfo where id =";
$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=fontsize:px;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 functionfind 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;
}
?>

上一篇:基于flush()不能按顺序输出时的解决办法

下一篇:zend Framework中的Layout(模块化得布局)详解