MYSQLI Admin Edit Table Question

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

MYSQLI Admin Edit Table Question

Post 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
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: MYSQLI Admin Edit Table Question

Post 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
}
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: MYSQLI Admin Edit Table Question

Post 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 :)
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Advanced Help and Support”