Hello All,
I am new to PHP but I have used ColdFusion a long time ago. I want to check for Null in a database and depending on if it is or not echo certain output. Here is an example of what I have tried so far but it does not seem to work.
<!-- Checks to see if URL is available if yes make company linkable, if not just echo company name. -->
if ($row->Web != Null) {
echo "<a href='$row->Web' target='_blank'>$row->Company</a><br>";
} else {
echo "$row->Company<br>";}
<!-- If first line of address exists, echo it. -->
if ($row->Add1 != Null) {
echo "$row->Add1<br>";}
<!-- If second line of address exists, echo it. -->
if ($row->Add2 != Null) {
echo "$row->Add1<br>";}
<!-- If city exists, echo city, state and zip. -->
if ($row->City != Null) {
echo "$row->City, $row->State $row->Zip";}
I am just checking to see if an address or URL is available and if so I echo the results. What am I doing wrong? My book does not cover this very well so I need to ask the experts.
Thanks,
Zych
I am new to PHP but I have used ColdFusion a long time ago. I want to check for Null in a database and depending on if it is or not echo certain output. Here is an example of what I have tried so far but it does not seem to work.
<!-- Checks to see if URL is available if yes make company linkable, if not just echo company name. -->
if ($row->Web != Null) {
echo "<a href='$row->Web' target='_blank'>$row->Company</a><br>";
} else {
echo "$row->Company<br>";}
<!-- If first line of address exists, echo it. -->
if ($row->Add1 != Null) {
echo "$row->Add1<br>";}
<!-- If second line of address exists, echo it. -->
if ($row->Add2 != Null) {
echo "$row->Add1<br>";}
<!-- If city exists, echo city, state and zip. -->
if ($row->City != Null) {
echo "$row->City, $row->State $row->Zip";}
I am just checking to see if an address or URL is available and if so I echo the results. What am I doing wrong? My book does not cover this very well so I need to ask the experts.
Thanks,
Zych