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.

MYSQLI Admin Edit Table Question

Postby Epiales » Thu Jul 02, 2015 11:17 pm

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
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: MYSQLI Admin Edit Table Question

Postby KyleMassacre » Fri Jul 03, 2015 7:54 am

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
}
Skype: KyleMassacre
My NWE Modules
User avatar
KyleMassacre
 
Posts: 567
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 19 times
Been thanked: 36 times

Re: MYSQLI Admin Edit Table Question

Postby Epiales » Fri Jul 03, 2015 10:22 pm

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
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times


Return to Advanced Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x