Birdmansplace Posted April 25, 2013 Share Posted April 25, 2013 I have a basic log in system setup for users to login. The users are admins and i want to be able to display all users but not there self. Basicly saying if tom, dick and my self are registered users when i see the list i dont want to see my name or if tom views the list he sees dick and my self. Because in this list i have a user delete fuction and don't want them to delete them self. Here is the code i have that displays it. <? session_start(); ?> <?php ini_set("display_errors", "1"); error_reporting(E_ALL); include("../dbinfo.php"); mysql_connect($host,$username,$password); // Connect to server and select database. mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM users ORDER BY username"; $result=mysql_query($sql) ?> <div align="center">Admin List</div> <br /> <table align="center" width="400" border="1" cellspacing="0" cellpadding="3" > <tr> <td align="center"><strong>Username</strong></td> <td align="center"><strong>Delete</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><? echo $rows['username']; ?></td> <td align="center"><a href="deletereg.php?sid=<? echo $rows['sid']; ?>"><input name="" type="button" value="Delete" /></a> </tr> <?php } ?> </table> <?php mysql_close(); ?> I was thinking some sort of "if" statment that could do this and just cant think of how to do it. Thanks for your help Link to comment https://forums.phpfreaks.com/topic/277292-display-all-users-but-not-my-self/ Share on other sites More sharing options...
Yohanne Posted April 25, 2013 Share Posted April 25, 2013 $query = mysql_query("SELECT * FROM users WHERE user_id != 'your_session_id'") mysql_query can do that.. Link to comment https://forums.phpfreaks.com/topic/277292-display-all-users-but-not-my-self/#findComment-1426508 Share on other sites More sharing options...
jugesh Posted April 25, 2013 Share Posted April 25, 2013 $sql="SELECT * FROM users Where userid ! ='your_user_id' ORDER BY username"; Link to comment https://forums.phpfreaks.com/topic/277292-display-all-users-but-not-my-self/#findComment-1426513 Share on other sites More sharing options...
Birdmansplace Posted April 26, 2013 Author Share Posted April 26, 2013 This is what code finally works for me. $sql="SELECT * FROM users Where sid !='session_start' ORDER BY username"; Link to comment https://forums.phpfreaks.com/topic/277292-display-all-users-but-not-my-self/#findComment-1426766 Share on other sites More sharing options...
Jessica Posted April 27, 2013 Share Posted April 27, 2013 What the? Link to comment https://forums.phpfreaks.com/topic/277292-display-all-users-but-not-my-self/#findComment-1426802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.