mardi 4 juin 2019

PHP if statement running regardless of the condition [duplicate]

This question already has an answer here:

I am currently trying to make a web page that only displays certain information in the form of HTML code if a variable has met a certain condition.

I have tried searching up ways of echoing HTML code and none of them have worked since the condition seemed to run anyway or I would be returned with a syntax error.

       <?php if ($activeDepartment = "Roadside Assistance") { ?>

                 <div class="x_panel">
                           <div class="x_title">
                              <h2>NCIC Name Lookup</h2>
                              <ul class="nav navbar-right panel_toolbox">
                                 <li><a class="collapse-link"><i class="fas fa-chevron-up"></i></a></li>
                              </ul>
                              <div class="clearfix"></div>
                           </div>
          </div>


      <?php } else {}?>


I expect the HTML code to only show if the variable is met however it is running regardless of what the variable is made. It could be made 'effdgg' and still show the HTML code.

Aucun commentaire:

Enregistrer un commentaire