现在,我确实在为此而努力,而且似乎不能让它发挥作用。 成员.php(我展示了所有登记用户) 我有一个名单,每个用户旁边有一个链接“ADD与FRIENDS”。
为了测试目的,我设法显示每个成员都很好(从而获得身份证),但当我点击其与朋友的联系时。 它在哪里似乎有过错。 我不知道如何让这位朋友在朋友们点击我。 php file. 请看一看!
members.php
<?php
include connect.php ;
include header.php ;
if(isset($_SESSION[ signed_in ]) == false || isset($_SESSION[ user_level ]) != 1 )
{
//the user is not an admin
echo <br/> ;
echo Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> to view all the <a href="signup_2.php" title="Become a registered user!"><b>registered</b></a> members. ;
echo <br/><br/> ;
}
else
{
echo <h2>Registered users:</h2> ;
$sql = "SELECT * FROM users ORDER BY user_name ASC";
$result = mysql_query($sql);
$num=mysql_numrows($result);
$i=0;
while ($i < $num)
{
//$name = mysql_result($result,$i,"user_name");
//$id = mysql_result($result,$i,"user_id");
//$picture = mysql_result($result,$i,"pic_location");
//?friend_id=" . $id .
while($user = mysql_fetch_array($result)){
echo $user[ user_name ]. <br/><br/><a href="friends.php?user= .$user[ user_id ]. ">ADD TO FRIENDS</a><br/> ;
echo $user[ user_id ];
echo <br/><br/> ;
}
$i++;
}
///////////////////////////////
/// adding users as friends ///
///////////////////////////////
//while($user = mysql_fetch_array($result))
//echo $user[ user_name ].
//<a href="addfriend.php?user= .$user[ id ]. ">ADD TO FRIENDS</a><br/> ;
//NOW I WANT TO MAKE A SPECIFIC "ADD AS FRIEND" LINK NEXT TO EACH USER
}
include footer.php ;
?>
正如我说过的那样,我不敢肯定如何做到这一点,请看一看! 感谢!
J. J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.J.
friends.php
<?php
include "connect.php";
include "header.php";
if(isset($_SESSION[ signed_in ]) == false || isset($_SESSION[ user_level ]) != 1 )
{
//the user is not an admin
echo <br/> ;
echo Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> if you want to add the person as a friend! ;
echo <br/><br/> ;
}
else
{
$sql = "SELECT * FROM users";
$result = mysql_query($sql);
//friend_id is the ID of the friend that is clicked on...
//HOW DO I GET THAT ID THAT IS CLICKED ON IN THE WHILE "loop" in members.php?
$friends = ("INSERT INTO friends SET user_id= " . $_SESSION[ user_id ] . " , friend_id= ".$id." , status= 0 ");
$result_friends = mysql_query($friends);
if(!$friends)
{
//When you can t add this person as a friend this error will show!
echo You cannot add this user at this time. Please try again later! ;
}
else
{
//When the friend is now added to the system!
echo Great! Now the user needs to approve before you can be friends! ;
}
}
?>