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