"Smriti Dev" <sm********@utoronto.ca> wrote in message news:<Hp********@campus-news-reading.utoronto.ca>...
Hi there,
I have the following code:
echo "\n <address>";
if ($entry_info[location] and $entry_info[location] != '') {
echo "\n ".stripslashes($entry_info[location]).".,";
}
if ($entry_info[address1] and $entry_info[address1] != '' ) {
echo "\n ".stripslashes($entry_info[address1]);
}
if ($entry_info[address2] and $entry_info[address2] != '' ) {
echo ',';
echo "\n ".stripslashes($entry_info[address2]);
}
If the mysql database does not have the field populated I do not want the .,
to appear in the address.
What can I put to show not equal to any data in the database.
Thanks in advance for your help.
Smriti
Hi Smriti,
I assume the location field in your database is string.
There are two possibilities:-
1. If you declare the field as *NULL-allowed field*
You can check for NULL value with is_null($entry_info['location']) function
2. If the field in database is declared as *NOT NULL field*
You can check for empty string $entry_info['location'] ==""
I think better way to do this checking is by merging these two conditions
with a single statement:
empty($entry_info['location'])
It will return false only when your location field is populated and non empty.
-- Rahul