Through a is_null
I can show a different content if there is a record or not in a specific column, without the need to perform another query.
description
If there is no NULL record in the column , the content that has the one echo
to be printed is not shown, but if there is content, it will be shown.
Example:
if(!is_null($row['description'])){
echo '<span class="toggle"></span>
<ul class="inner"><div class="aaaaaaa">
<li>'.$row['description'].'</li></div>
</ul>';
}
In the same way or something similar without the need to perform another query or a new query, how can I show a link only if vista_previa
the word exists in the column yes
and if the word exists not
, not show the link.
id | vista_previa | description | url
1 yes one one.php
2 not two two.php
<a href="'.$row['url'].'"></>
You already have the code! I suggest that in your query to the DB (you do not indicate what it is) you add as appropriate so that instead of NULL it returns a value (for example, an empty string) in MySQL it would be (using IsNull() with IF() :
with the above instead of
would be
therefore for the case you ask it would be
then use the ternary operator (or conditional operator)
?
: