Page 1 of 1

php code- need help

Posted: Sat Apr 02, 2011 5:01 pm
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...

Re: php code- need help

Posted: Sat Apr 02, 2011 5:12 pm
by fugix
I would set up a $_SESSION['username'] and tell the query to grab all of the usernames except the $_SESSION['username']

Re: php code- need help

Posted: Sat Apr 02, 2011 5:17 pm
by mastersan
Please mabe you can show some example. I am realy new in coding.

Re: php code- need help

Posted: Sat Apr 02, 2011 5:20 pm
by fugix
well you said that you know how to get the list...so show me that code

Re: php code- need help

Posted: Sat Apr 02, 2011 5:30 pm
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).

Re: php code- need help

Posted: Sat Apr 02, 2011 5:59 pm
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'] ";