0

I want to make link with condition. i have a database table named admin. there is a field name registration. if that value is Y then i redirect this otherwise no that's i am expecting. if anyone suggest me it will so much helpful.

  $sql4 = "SELECT * FROM admin ";
  $result4 = mysqli_query($con,$sql4);
  $row4 = mysqli_fetch_array($result4,MYSQLI_ASSOC);
  $re = $row4['registration'];
 /////////////////////////////////////////////
 <a href = <?php if ($re='Y') { ?> "registration.php" <?php } 
else {echo "no";}?>class = "btn btn-primary btn-lg" role = "button">
             Registration
           </a>
Mithun
  • 73
  • 3
  • 10

2 Answers2

0

You're using an assignment:

($re='Y')

You need a comparison:

($re=='Y')
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
0

You can achieve this is may ways. The easiest would be:

<?php if ($re == 'Y') : ?>
  <a href="registration.php" class="btn btn-primary btn-lg" role="button">Registration</a>
<?php else: ?>
  <a href="login.php" class="btn btn-primary btn-lg" role="button">Login</a>
<?php endif; ?>
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60