Jump to content

Need help displaying members


bytesize

Recommended Posts

$_GET["find"] displays all users including the current user. The current user should not be displayed.

 

I would like to display members that are NOT friends with the current user. Do I need to join the tables to make this work?

 

$_GET["add"] inserts "screen_name" into "member and friendwith"

 

<?php
if(isset($_GET["find"]))
{	
$username = $_POST["screen_name"];
$query = "SELECT * FROM users WHERE screen_name LIKE '%$username%'";
$result = mysql_query($query);
$exist = mysql_num_rows($result); 
if($exist=='0')
{
 echo "No match found";
}
else 
{
 echo "Matches for search: $username<br>";
 while($currow = mysql_fetch_array($result))
 {
 ?>
	<a href="users/member?addfriend=<?php echo $currow['screen_name']; ?>"><img src="avatars/<?php echo $currow["image"]; ?>" ></a>
	<?php
 }
}
}

if(isset($_GET["add"]))
{ 
$username = $_SESSION["screen_name"];
$friend = $_GET["add"];
$query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'";
$result = mysql_query($query);
$exist = mysql_num_rows($result); 
if($exist=='0')
{
 $query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')";
 mysql_query($query);
 echo "$friend is now your friend!";
}
else 
{
 echo "$friend is already your friend!";
} 
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.