Question: How can I show or hide div depending on result come from server, in the file that handle the request, I get a customer object from db, depending on user request, if I didn't find the corresponding customer I want to hide a div .

here's my php code

```
 $customer=getCustomerViaCellPhone($link,$cellPhoneNo);
if(!$customer){
   $error = 'No result found';
}

```

here's the view 

```
<div id="customerInfo" class="<?php (is_null($customer))?'hide':''?>">
....
</div>

```

but it shows the div in both cases

Answer: 
According to your comment, `$customer` is **not** `NULL`, it's an object with `NULL` values in it. Which will return false for your `is_null($customer)` check because it's not [`NULL`*Docs*](http://www.php.net/manual/en/language.types.null.php) - it is an object.

You can solve this by decoupling the output logic from your data a bit:

```
$customer=getCustomerViaCellPhone($link,$cellPhoneNo);
$hideCustomerInfo = false;
if(!$customer) {
   $error = 'No result found';
   $hideCustomerInfo = true;
}

```

and in the view then:

```
<div id="customerInfo" class="<?php echo $hideCustomerInfo ? 'hide' : ''; ?>">
....
</div>

```

In case this does not work, you can validate the `$hideCustomerInfo` flag already in you controller to see if it contains the value you expect. Additionally this simplifies your view.

Next to that ensure your CSS is correct as well to hide HTML elements with such a class.
```
<div id="customerInfo" style="display:<?php echo (is_null($customer))?'none':'block'?>">

```

Take a look at css' [display](http://www.w3schools.com/cssref/pr_class_display.asp) and [visibility](http://www.w3schools.com/cssref/pr_class_visibility.asp) options