我有以下关于添加新朋友的脚本。它在两种情况下都可以正常工作,并且在一侧有问题。例如,如果 A 向 B 和 C 发送好友请求。当 B 接受他的请求时,C 仍然没有接受。如果 C '等待批准'正在工作。条件 1 不起作用。意味着即使 A 是您的朋友,您仍然可以发送请求。下面是脚本:
<?php
$querToCheck = "SELECT * FROM friends WHERE accepted = '2' AND ((user_one = '$activeID' AND user_two = '$fid') OR (user_one = '$fid' AND user_two = '$activeID' ) )";
$resToCheck = mysql_query($querToCheck);
if(mysql_num_rows($resToCheck)==2)
{
$addFriend = "Friends";
}
else
{
$querToCheck = "SELECT * FROM friends WHERE accepted = '1' AND ((user_one = '$activeID' AND user_two = '$fid') OR (user_one = '$fid' AND user_two = '$activeID' ) )";
$resToCheck = mysql_query($querToCheck);
if(mysql_num_rows($resToCheck)==1)
{
$addFriend = "Waiting For Approval";
}
else
{
$querToCheck = "SELECT * FROM friends WHERE accepted = '0' AND ((user_one = '$activeID' AND user_two = '$fid') OR (user_one = '$fid' AND user_two = '$activeID' ) )";
$resToCheck = mysql_query($querToCheck);
if(mysql_num_rows($resToCheck)==0)
{
$addFriend = '<a href="addAsFriend.php?sid='.$row['id'].'" style="color:#FFFFFF;font-size:14px;">Add As Friend</a>';
}
}
}
}
?>