Reputation: 13
I got a code that would display the date value from a database column based on it's id but the problem is..
When I'm trying to put a new data which sets the ID to null, I'm having an error because it can't fetch the data so I've tried using if statements.
here it is
<input id="product_expirations" name="product_expirations" type="date" value="
<?php
if ($products){
}else
echo $products->product_expirations;?>"
class="form-control">
I don't know what parameter to be put beside if $products. please help me. Thanks in advance
Upvotes: 1
Views: 121
Reputation: 38652
you can just write single line if
<input id="product_expirations" name="product_expirations" type="date" value="<?php echo (!empty($products)) ? $products->product_expirations; : '' ?>" class="form-control">
Syntax for single line if
(condition) ? TRUE: FALSE
Upvotes: 2