Page 1 of 1

MYSQLI Admin Edit Table Question

Posted: Fri Jul 03, 2015 4:17 am
by Epiales
Okay you lovely guys and gals...

Ran across an issue I can't figure out.

I am creating an admin page that shows the usernames. By each username there is an edit image allowing the admin to edit the users information. Is there a way that it will not show the edit image in the echoed usernames so that no one can edit the main admins account? I've tried a few different ways, but can't seem to figure it out. Here is the code:

Code: Select all

<?php
$sql = "SELECT * FROM users ORDER BY username ASC";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {

?>    
    <table>
 <td width="25%"><?php echo $row['ID'];?></td><td width="50%"><?php echo $row['username'];?></td><td width=35%><a href="edit_user.php?id=<?php echo $row['ID'];?>&username=<?php echo $row['username'];?>"><img src="../image/user_edit.png" title="Edit User Account"></a> </td>
As you see, it's basic code. I want it to display all the users in the database, with an image that allows admins to click on it to edit each user ( it already does this) , but I don't want the MAIN ADMINS account able to be edited.

Any Ideas? Thx

Re: MYSQLI Admin Edit Table Question

Posted: Fri Jul 03, 2015 12:54 pm
by KyleMassacre
You can do something like:

Code: Select all

$notAllowed = array(1,2,3,4); //put the user ids here you want to filter out
if(!in_array($row['ID'],$notAllowed)) {
    //put all the goodies in here
}

Re: MYSQLI Admin Edit Table Question

Posted: Sat Jul 04, 2015 3:22 am
by Epiales
KyleMassacre wrote:You can do something like:

Code: Select all

$notAllowed = array(1,2,3,4); //put the user ids here you want to filter out
if(!in_array($row['ID'],$notAllowed)) {
    //put all the goodies in here
}
TYTY :)