S
S
Sergey Goryachev2016-10-27 22:31:24
PHP
Sergey Goryachev, 2016-10-27 22:31:24

How to write a condition if the variable is equal to -1?

In Joomla, if you select "Nothing selected", the variable is set to -1.
How to correctly write a condition so that if the $music variable is equal to -1, then the block is not shown?

<?php ... { ?>
<!-- audio -->
<div class="player">
    <audio id="player" src="<?php echo $music ?>" loop="loop" preload="auto"></audio>
    <div class="player__btn"></div>
</div>
<!-- /audio -->
<?php } ?>

On "exit" I have the following code.
<!-- audio -->
<div class="player">
    <audio id="player" src="-1" loop="loop" preload="auto"></audio>
    <div class="player__btn"></div>
</div>
<!-- /audio -->

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-10-27
@webirus

<?php if($music != -1) { ?>
Or is there something wrong here? :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question