Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

php查询记录数问题,count异常

    mysql_select_db("zaiping", $con);
    $result = array();
    $rs = mysql_query("select count(*) as count from dept where deptName like $deptName");
    $row = mysql_fetch_array($rs);
    ChromePhp::log($row);
    $result["total"] = $row[0];

sql命令行执行select count(*) as count from dept where deptName like $deptName是没有问题的,如果记录数>=2也是没问题的,问题就是当有1条匹配数据时$result["total"]=0,这是为什么,为什么不是1?谢谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
你把$row[0]改成$row[0]['count']试试;显示过滤了

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...