How to check if record in MySQL Database is Null in PHP Programming

In Development web or App, sometimes we need to check if record is exist in our record. To do this, we can execute php code like below

$sql_pn ="SELECT * FROM tbl_phone WHERE date_format(last_receive_ft, '%Y-%m-%d')!=date_format(now(), '%Y-%m-%d') LIMIT 1";
    $sql_pn = $link->query($sql_pn);
    $pn = mysqli_fetch_array($sql_pn);
    $phone = $pn['no_hp'];
    
    if (mysqli_num_rows($sql_pn) == 0 ) {
        die('tada record');
    }

 Line 6 is the code to get out process from loop.

If query result  = 0 process loop end.

Related Articles