I have a php script that pulls data from a mysql database that works perfectly. It pulls the id, city, state and username from a database. In some instances, the city and state values are null and I want the script to print 'N/A' instead. What do I need to add to my script below to do that?
<?php
// SQL database Variables
$connection = mysql_connect("localhost","username","password")
or die("Couldn't make connection.");
$db_name='mydb';
$sql="SELECT * from temp_user where temp_id='$temp_id'";
$result= mysql_db_query($db_name,$sql,$connection) or die
("Could not execute query : $sql." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$temp_id=$row["temp_id"];
$city=$row["city"];
$state=$row["state"];
$username=$row["username"];
}
echo "<br><b>Name: $temp_id<BR>\n";
echo "City: $city<BR>\n";
echo "State: $state<br>\n";
echo "Username: $username<br>\n";
?>