how can I make this inquiry?

0

How can I make a message in the table account instead of a 0 ?

    $notification_info = mysql_query("SELECT count(*) as cuenta from notification WHERE viewed='viewed_no_$uid'");
    if (mysql_num_rows($notification_info) == 0)
    {
             echo 'No tienes Contenido';

    }else{  

        while($res=mysql_fetch_assoc($notification_info)){

            echo ''.(string) $res["cuenta"].'';

        }
    }
    
asked by Shareiv 10.03.2017 в 18:08
source

2 answers

2
if ($res["cuenta"] == 0) {
    echo 'NO TIENE CONTENIDO';
} else {
    echo (string)$res["cuenta"];
}

This way if the account is 0 , it prints NO TIENE CONTENIDO ; otherwise, it prints the value of $res["cuenta"] .

    
answered by 10.03.2017 / 18:22
source
2

Try this:

$notification_info = mysql_query("SELECT CASE count(*) WHEN 0 THEN 'No tiene contenido' ELSE count(*) as cuenta from notification WHERE viewed='viewed_no_$uid'");
    
answered by 10.03.2017 в 18:33