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
https://forums.phpfreaks.com/topic/220731-need-help-displaying-members/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.