手机
当前位置:查字典教程网 >编程开发 >php教程 >解析link_mysql的php版
解析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>".$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;

}

?>

【解析link_mysql的php版】相关文章:

20个2014年最优秀的PHP框架

Windows下PHP的任意文件执行漏洞

php代码优化及php相关问题总结

不用GD库生成当前时间的PNG格式图象的程序

自动跳转中英文页面

PHP也可以當成Shell Script

无数据库的详细域名查询程序PHP版(2)

PHP文件读取功能的应用实例

PHP中在数据库中保存Checkbox数据(1)

透析PHP的配置文件php.ini

精品推荐
分类导航