如果列值为0或小于0或null,则打印false;如果value大于0,则打印true

时间:2014-04-03 06:53:31

标签: php

我正在尝试创建一个从数据库中获取值的网页.i从表councel名称councel名称获取3列,smscount emailcount,我想如果smscount和emailcount值为null或0或小于0则打印false和如果value大于0则打印为true。 我该怎么做这个任务。 从表列获取值的代码是

     <?php 
      // Connects to your Database 
     mysql_connect("localhost", "root","root") or die(mysql_error()); 
     echo "connec to local host"; 
     mysql_select_db("Court") or die(mysql_error());
     echo "connec to Database"; 
     $data = mysql_query("SELECT * FROM councel") 
     or die(mysql_error()); 
     Print "<table border cellpadding=3>"; 
     while($info = mysql_fetch_array( $data )) 
     { 
     Print "<tr>"; 
     Print " <td>".$info['CouncelName'] . "</td> "; 
     Print " <td>".$info['SMSCount'] . "</td> "; 
     Print " <td>".$info['EmailCount'] . " </td></tr>"; 
     } 
     Print "</table>"; 
     ?> 


      ![enter image description here][1]

1 个答案:

答案 0 :(得分:0)

假设您的值是整数,您可以这样做:

if($info['EmailCount'] && $info['SMSCount'] && $info['EmailCount'] >= 0 && $info['SMSCount'] >= 0){
    echo "true";
}else{
    echo "false";
}