解析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;
}
?>
相關(guān)文章
PHP 事務(wù)處理數(shù)據(jù)實現(xiàn)代碼
PHP 事務(wù)處理數(shù)據(jù)實現(xiàn)代碼,需要的朋友可以參考下。2010-05-05修復(fù)ShopNC使用QQ 互聯(lián)時提示100010 錯誤
本文給大家介紹了修復(fù)ShopNC使用QQ 互聯(lián)時提示100010 錯誤的方法,以及QQ互聯(lián)里面的處理方法,有需要的小伙伴可以參考下2015-11-11php empty,isset,is_null判斷比較(差異與異同)
做php開發(fā)時候,想必在使用:empty,isset,is_null 這幾個函數(shù)時候,遇到一些問題。甚至給自己的程序帶來一些安全隱患的bug。很多時候,對于isset,empty都認為差不多。因此開發(fā)時候,就沒有注意,一段作為流程判斷時候,就出現(xiàn)bug問題了。2010-10-10jQuery ajax+PHP實現(xiàn)的級聯(lián)下拉列表框功能示例
這篇文章主要介紹了jQuery ajax+PHP實現(xiàn)的級聯(lián)下拉列表框功能,涉及php結(jié)合jQuery的$.get方法動態(tài)交互實現(xiàn)省市二級聯(lián)動下拉列表框相關(guān)操作技巧,需要的朋友可以參考下2019-02-02PHP管理依賴(dependency)關(guān)系工具 Composer的自動加載(autoload)
Composer 是PHP的一個包依賴管理工具,類似Ruby中的RubyGems或者Node中的NPM,它并非官方,但現(xiàn)在已經(jīng)非常流行。此文并不介紹如何使用Composer,而是關(guān)注于它的autoload的內(nèi)容吧。2014-08-08