Help with IF NULL

I have the following code and when reading on the Internet I have a hard time understanding where to place the IF NULL command.

Basically I have $row[8] that could be either with data or empty.

If empty I would like to return the word “empty”.

// $row[0] ID
// $row[1] NAZIONE
// $row[2] REGIONE
// $row[3] LOCALITA
// $row[4] DATA
// $row[5] TITOLO
// $row[6] DESCRIZIONE
// $row[7] INTERNET
// $row[8] EMAIL

$sqltoscana = mysql_query(“SELECT * FROM calendario ORDER BY REGIONE ASC”);
while ($row = mysql_fetch_row($sqltoscana)) {
echo "

   $row[4] - $row[3]. “$row[5]”. $row[6] $row[7] / $row[8]";
}
echo “

”;

Can you please help?

Thank you in advance.

For starters. You are using obsolete mysql calls. You need to use PDO or Mysqli.

It is best to let the database do the work for you and handle the problem in SQL.

[code]SELECT ID,
NAZIONE,
REGIONE,
IF(EMAIL IS NULL,‘Empty’,EMAIL) EMAIL,

FROM YourTable;[/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service