Removing null values from mysql output

In the following code:
PHP:
$html = <<<EOF
            <div class "{$class}">{$content}</div> 
EOF;

There should be no whitespace after <<<EOF or before EOF;
The code within will appear greyed out in most editors.
 
I still can't get it working, I'll take a look tomorrow with fresh eyes. Thanks everyone for getting this working...

visibleman, after some reading it appears the ? !empty :

Is a fancy way of doing an if statement.

If a value is not emtpy then execute the bit after ? else its false (colon) and output "" which outputs no html markup, therefore it doesn't show anything on my html page.

Is that it in very basic terms?
 
visibleman, after some reading it appears the ? !empty :

Is a fancy way of doing an if statement.

If a value is not emtpy then execute the bit after ? else its false (colon) and output "" which outputs no html markup, therefore it doesn't show anything on my html page.

Is that it in very basic terms?

It's called a ternary operator or ternary if statement; essentially a shortened if statement -
( *condition* ) ? *condition true* : *condition false*

And yup, it'll work as you suggested and won't output that particular line/HTML if the table column field is empty (NULL).


However, is there a particular reason why you're using heredoc syntax for strings rather than the standard quotation in your examples?
 
It's called a ternary operator or ternary if statement; essentially a shortened if statement -
( *condition* ) ? *condition true* : *condition false*

And yup, it'll work as you suggested and won't output that particular line/HTML if the table column field is empty (NULL).


However, is there a particular reason why you're using heredoc syntax for strings rather than the standard quotation in your examples?

No, no reason, it's just how I learnt to do it from googling. I have bought a couple of php books and am slowly going to go through them, IF I can understand variables, strings, operators, functions & classes I think that will cover. I know a lot more now than I did in 2010, but I haven't followed a structure of learning as I am trying to get my first project completed.

I have found a nice beginner guide at http://www.tuxradar.com/practicalphp
 
Back
Top Bottom