malkocoglu Posted May 14, 2013 Share Posted May 14, 2013 Dear users, I am trying to disregard ADMIN when displaying registered users from USERS table. The code I am using is if($session->isAdmin()) {$query="SELECT username FROM users ";} This gives me all the users from the database. What I want to do is not to display ADMIn and display the rest of the users. is it possible? Could anyone help? Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/ Share on other sites More sharing options...
Jessica Posted May 14, 2013 Share Posted May 14, 2013 Use a WHERE clause on your query. Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429936 Share on other sites More sharing options...
mac_gyver Posted May 14, 2013 Share Posted May 14, 2013 you would add a WHERE term to your query that either excludes the admins or selects everyone but admins, whichever is easier to do. edit, lol, see the above reply by jessica. Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429937 Share on other sites More sharing options...
malkocoglu Posted May 14, 2013 Author Share Posted May 14, 2013 Thanks for quick replies. Could you possible wrote the code where it excludes the ADMIN? Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429941 Share on other sites More sharing options...
Psycho Posted May 14, 2013 Share Posted May 14, 2013 Thanks for quick replies. Could you possible wrote the code where it excludes the ADMIN? No, because we have no idea what you may, or may not, have in your database to identify what an ADMIN is. Do you have a column called "admin" with a 0/1 value? SELECT username FROM users WHERE admin = 0 Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429942 Share on other sites More sharing options...
malkocoglu Posted May 14, 2013 Author Share Posted May 14, 2013 Ok. what I have is a table called users and in that table there are the following; username password userid userlevel email timestamp Admin doesn not have a value Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429944 Share on other sites More sharing options...
davidannis Posted May 14, 2013 Share Posted May 14, 2013 try if($session->isAdmin()) {$query="SELECT username FROM users WHERE `username` !=' ADMIN' ";} Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429945 Share on other sites More sharing options...
malkocoglu Posted May 14, 2013 Author Share Posted May 14, 2013 try if($session->isAdmin()) {$query="SELECT username FROM users WHERE `username` !=' ADMIN' ";} Thanks for the reply but it didnt work.. Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429946 Share on other sites More sharing options...
malkocoglu Posted May 14, 2013 Author Share Posted May 14, 2013 I have realised that the user names are lowercase, it worked After changing the ADMIN to admin. Thanks a lot Link to comment https://forums.phpfreaks.com/topic/277973-how-not-to-display-admin-when-fetching-data-from-mysql-user-table/#findComment-1429948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.