Reputation: 1
So I have a button that I want to show and hide on certain parts.
So if $unlockcourse
is false AND the $courseid
is 1, I would like the button to be hidden, BUT I would like it to be shown at all other times no matter what the courseid
is
$courseid = ($userinfo['course']) * 1;
$mycourse = ($userinfo['id_course']) * 1;
$unlockcourse = true;
if($haspaid == 1){
$unlockcourse = false;
} else if ($haspaid == 0) {
$unlockcourse = true;
}
<?php if ($unlockcourse == false && $mycourse >= 1) { ?>
<a href="course-work-proc.php" class="btn btn-primary">Resume Course</a>
<?php } ?>
Upvotes: 0
Views: 905
Reputation: 5013
So what you actually want to do is show it if unlockcourse is false, and mycourse is 1. This means that to find out when to show it, you need to negate both conditions like this:
<?php if (!($unlockcourse == false && $mycourse == 1)) { ?>
<a href="course-work-proc.php" class="btn btn-primary">Resume Course</a>
<?php } ?>
Upvotes: 0
Reputation: 48
Try Editing the following code
<?php if ($unlockcourse == false && $mycourse >= 1) { ?>
<a href="course-work-proc.php" class="btn btn-primary">Resume Course</a>
<?php } ?>
into
<?php if !($unlockcourse == false && $mycourse >= 1){
echo "<a href='course-work-proc.php' class='btn btn-primary'>Resume Course</a>";
}?>
This will make the button appear when your statements are true, and nothing will appear when the statement is false
Upvotes: 1
Reputation: 167182
I am surprised how did this not throw an error. The error lies here:
if ($unlockcourse == false) && if ($mycourse == 1) && {
It should be:
if ($unlockcourse == false && $mycourse == 1) {
Upvotes: 1