熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

解析link

2022-06-13   來源: PHP編程 
本篇文章是對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;
}
?>


From:http://tw.wingwit.com/Article/program/PHP/201311/21156.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.