盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

MySQL NULL 值处理案例图文说明教程

时间:2025/3/7作者:未知来源:盾怪网教程人气:

[摘要]+ ----------------- + ---------------- +2行(0.00秒)使用PHP脚本处理NULL值PHP脚本中你可以在if ... else语句来处理变量是否为空,并生成...
+ ----------------- + ---------------- + 2行(0.00秒)

使用PHP脚本处理NULL值

PHP脚本中你可以在if ... else语句来处理变量是否为空,并生成相应的条件语句。

以下实例中PHP设置了$ tutorial_count变量,然后使用该变量与数据表中的tutorial_count字段进行比较:

<?PHP
$ dbhost ='localhost:3036';
$ dbuser ='root';
$ dbpass ='rootpassword';
$ conn = mysql_connect($ dbhost,$ dbuser,$ dbpass);
if(!$ conn)
{
  die('无法连接:'。mysql_error());
}
if(isset($ tutorial_count))
{
   $ sql ='SELECT tutorial_author,tutorial_count
           FROM tcount_tbl
           WHERE tutorial_count = $ tutorial_count';
}
其他
{
   $ sql ='SELECT tutorial_author,tutorial_count
           FROM tcount_tbl
           WHERE tutorial_count IS $ tutorial_count';
}
mysql_select_db( '教程');
$ retval = mysql_query($ sql,$ conn);
如果(!$ retval)
{
  die('无法获取数据:'mysql_error());
}
while($ row = mysql_fetch_array($ retval,MYSQL_ASSOC))
{
    echo“作者:{$ row ['tutorial_author']} <br>”。
         “Count:{$ row ['tutorial_count']} <br>”。
         “--------------------------------结果”;
} 
echo“成功获取数据\ n”;
mysql_close($康恩);
?>

【相关推荐】

1. 特别推荐:“php程序员工具箱”V0.1版本下载

2. 免费mysql在线视频教程

3. 数据库设计那些事

以上就是MySQL NULL 值处理实例教程的详细内容,更多请关注php中文网其它相关文章!


学习教程快速掌握从入门到精通的SQL知识。



关键词:MySQL NULL 值处理案例图文详细教程




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版