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"]; ?>" /></td>
The button can be find inside a table as follows,
<div id="employee_table">
<table >
<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"]; ?>" /></td>
</tr>
<?php
}
?>
</table>
</div>
I need to hide my UPDATE button by checking the value of a mysql field, like below;
if($row["username"]=='John')
{
//hide button
}
else{
//show UPDATE button
}
To get a better understanding I will put a table as well,,
can someone show me how to do this?
CodePudding user response:
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"]; ?>" />
<?php } ?>
</td>