[摘要]+ ----------------- + ---------------- +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 值处理案例图文详细教程