Checking for an empty field with MySQL

前端 未结 7 530
有刺的猬
有刺的猬 2020-12-12 14:58

I\'ve wrote a query to check for users with certain criteria, one being they have an email address.

Our site will allow a user to have or not have an email address.<

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 15:22

    check this code for the problem:

    $sql = "SELECT * FROM tablename WHERE condition";
    
    $res = mysql_query($sql);
    
    while ($row = mysql_fetch_assoc($res)) {
    
        foreach($row as $key => $field) {  
    
            echo "
    "; if(empty($row[$key])){ echo $key." : empty field :"."
    "; }else{ echo $key." =" . $field."
    "; } } }

提交回复
热议问题