php code- need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mastersan
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 7:52 pm

php code- need help

Post by mastersan »

I whant to displey list of usernames but in that list must not be listed that username which is looking on this list.
I cnow how to get the list but i am stuck whit the other part...
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: php code- need help

Post by fugix »

I would set up a $_SESSION['username'] and tell the query to grab all of the usernames except the $_SESSION['username']
mastersan
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 7:52 pm

Re: php code- need help

Post by mastersan »

Please mabe you can show some example. I am realy new in coding.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: php code- need help

Post by fugix »

well you said that you know how to get the list...so show me that code
mastersan
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2011 7:52 pm

Re: php code- need help

Post by mastersan »

Some like this

Code: Select all

<?php
$db = mysql_connect('....','.....','.....') or die();
mysql_select_db('....', $db);
$result = mysql_query("set names 'utf8'");
$query = "select * from users username";
$result = mysql_query($query);
$userrow = mysql_fetch_array( $result );
echo "User name list-<br>";
while($userrow = mysql_fetch_array($result)){
			$username=$userrow['username'];
			echo $username;		
			echo "<br>";
}
?>
This code i will mode and add it in form and each user will be like value for radio type input, thats why i don't whant that user who looking on this list can see him self(seleckt him self in my form).
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: php code- need help

Post by fugix »

so what you are going to do is set up a session with the persons username, so when they login a session with their username is stored...then you are going to edit this line of code

Code: Select all

$query = "select * from users WHERE username != $_SESSION['username'] ";
Post Reply