解析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使用Cookie實(shí)現(xiàn)和用戶會(huì)話的方法
這篇文章主要介紹了php使用Cookie實(shí)現(xiàn)和用戶會(huì)話的方法,分析了Cookie的原理、設(shè)置與使用技巧,需要的朋友可以參考下2015-01-01
一個(gè)PHP數(shù)組應(yīng)該有多大的分析
PHP在數(shù)組處理上非常低效,尤其是內(nèi)存占用較多,常常使得httpd進(jìn)程消耗太多資源。2009-07-07
用sql命令修改數(shù)據(jù)表中的一個(gè)字段為非空(not null)的語句
今天群里的一個(gè)朋友問如何用sql命令修改數(shù)據(jù)表中的一個(gè)字段為非空(not null),經(jīng)常測(cè)試下面的代碼即可。2010-06-06
php + ajax 實(shí)現(xiàn)的寫入數(shù)據(jù)庫操作簡(jiǎn)單示例
這篇文章主要介紹了php + ajax 實(shí)現(xiàn)的寫入數(shù)據(jù)庫操作,結(jié)合實(shí)例形式分析了php + ajax 寫入數(shù)據(jù)庫基本原理、操作技巧與相關(guān)使用注意事項(xiàng),需要的朋友可以參考下2020-05-05
php實(shí)現(xiàn)自運(yùn)行的實(shí)例詳解
在本篇文章里小編給大家整理的是一篇關(guān)于php實(shí)現(xiàn)自運(yùn)行的實(shí)例詳解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)參考下。2021-07-07

