Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to hide a button according to a Rule

I have a button which makes a function to edit a row in mysql table. The button is as follows,

<td><input type="button" name="edit" value="UPDATE" id="<?php echo $row["ID"]; ?>" class="btn btn-info btn-xs edit_data" /></td>

The button can be find inside a table as follows,

<div id="employee_table">
     <table class="table table-bordered">
     <tr>
    <th width="30%">Username</th>
     <th width="10%">Change</th>
      </tr>
      <?php
      while($row = mysqli_fetch_array($result))
      {
      ?>
      <tr>
       <td><?php echo $row["username"]; ?></td>
        <td><input type="button" name="UPDATE" value="Mark as Received" id="<?php echo $row["ID"]; ?>" class="btn btn-info btn-xs edit_data" /></td>
      
       
      </tr>
      <?php
      }
      ?>
     </table>
    </div>

I need to hide my UPDATE button by checking the value of a mysql field, like below;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if($row["username"]=='John')
{
//hide button
}
else{
//show UPDATE button
}

To get a better understanding I will put a table as well,,

enter image description here

can someone show me how to do this?

>Solution :

Just enclose the button with if statement like this

<td>
    <?php if($row["username"]!='John'){ ?>
         <input type="button" name="UPDATE" value="Mark as Received" id="<?php echo $row["ID"]; ?>" class="btn btn-info btn-xs edit_data" />
    <?php } ?>
</td>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading