Im trying to display an address properly formatted, but empty fields in mysql table come out as blank spaces, as below. Does anyone have any tips for getting round this?
The code below gives output like this;
Address housenumber
streetname
postcode
What im trying to do is show the address as;
Address housenumber
streetname
postcode
First i`m not sure if the code below is correct, and second whether the column type in mysql are correct, i have tried all variations of NULL and not NULL, TEXT and VARCHAR.
Thanx in advance
ollie
$result = mysql_query("SELECT * FROM fran WHERE ID = '$ID'");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
$ID = $row["ID"];
$contact = $row["contact"];
$add1 = $row["add1"];
$add2 = $row["add2"];
$add3 = $row["add3"];
$add4 = $row["add4"];
$add5 = $row["add5"];
$postcode = $row["postcode"];
$a = "";
if( "$add2" !=="" )
{
$a = $a . $add2 . "<br>";
}
if( "$add3" !=="" )
{
$a = $a . $add3 . "<br>";
}
if( "$add4" !=="" )
{
$a = $a . $add4 . "<br>";
}
if( "$add5" !=="" )
{
$a = $a . $add5 . "<br>";
}
if( "$postcode" !=="" )
{
$a = $a . $postcode . "<br>";
}
$tel = $row["tel"];
$fax = $row["fax"];
$web = $row["web"];
$type = $row["type"];
$invest = $row["invest"];
$profile = $row["profile"];
$paid = $row["paid"];
}