我数据库中dc表中dc1字段有两种值,是和不是,现在我要统计是的有多少个,不是的有多少个。我自己写的统计代码不对。
是在php中用
<?php 
$dc01=mysql_query("select count('是') from dc where dc1);
echo"$dc01"
?>

解决方案 »

  1.   

    $dc01=mysql_query("select count(*) from dc where dc1='是'");
    $result = mysql_fetch_row($dc01);
    print_r($result);//$result[0]应该就是你要的结果
      

  2.   

    结果的确是我要的。
    但是内容显示
    选择是的有【 Array ( [0] => 2 ) 】人
    我想变成
    选择是的有【 2 】人
    用echo输入就只有array?
      

  3.   

    搞定了。谢谢!
    <?php 
    $dc01=mysql_query("select count(*) from dc where dc1='是'");
            $result = mysql_fetch_row($dc01);

            print_r($result[0]);//$result[0]应该就是你要的结果
    ?>