Am very new to PHP and I'm displaying an address from mysql which has fields
Company
Add1
Add2
Add3
Add4
Postcode
I use mysql_fetch_row to get the Company I choose from a drop down menu then echo out each row. The problem I have is some addresses don't have an Add3 or Add4.
So my question is if a variable doesn't contain anything can I use an If statement to ignore displaying it?
I thought about isset but it will always be set even if it contains nothing.
Company
Add1
Add2
Add3
Add4
Postcode
I use mysql_fetch_row to get the Company I choose from a drop down menu then echo out each row. The problem I have is some addresses don't have an Add3 or Add4.
So my question is if a variable doesn't contain anything can I use an If statement to ignore displaying it?
I thought about isset but it will always be set even if it contains nothing.
Code:
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM delivery WHERE company = '$company'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo "<font face='Arial'><br><br>Invoice address:<br><br>";
echo $row[2]."<br>"; // Company
echo $row[3]."<br>"; // Add1
echo $row[4]."<br>"; // Add2
echo $row[5]."<br>"; // Add3
echo $row[6]."<br>"; // Add4
echo $row[7]."<br>"; // Postcode