Php mariadb sum divided by if there is no value, can NAN, be shown as 0?

$selectTip = $pdo->query("SELECT * FROM `tips_rate`
                WHERE `tip_id` = "".$row["id"]."" "
              );
              $selecttotal = mysqli_num_rows($selectTip);
              $rate = $pdo->query("SELECT SUM(star) as startotal FROM `tips_rate`
                WHERE `tip_id` = "".$row["id"]."" "
              );
              $startotal = mysqli_fetch_array($rate);
              echo $startotal["startotal"]/$selecttotal;

when we echo the result of their division by
there is no value, he will see NAN.. Can you show me 0?

Feb.26,2021

$num = $startotal ['startotal'] / $selecttotal;
echo is_nan ($num)? 0: $num;

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c1fb95-334a0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c1fb95-334a0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?