Hi all, i've recently made a friends script that adds the id of user who requested the friend (user) and the requestee (req), with a confirmed column, 0 if pending, 1 if accepted.
i was looking for a way to search through the friends table for all friends of a certain id, i would need to search user column and req column where confirmed =1, then put all the values into an array and list them on the profile page. but im stuck,
$connect = mysql_connect("localhost", "root", "") or die (mysql_error());
$connect;
mysql_select_db ("phplogin");
$userfriend = mysql_query ("SELECT req FROM friends WHERE user='$profileid' AND confirmed=1");
$userfriendarray = mysql_fetch_array($userfriend);
$userfriendreq = $userfriendarray['req'];
$userreq = mysql_query ("SELECT user FROM friends WHERE req='$profileid' AND confirmed=1");
if ($userreq != 0)
{
$userreqarray = mysql_fetch_array($userreq);
$userreq2 = $userreqarray['user'];
}
if ($userreqarray != 0 && $userfriendarray!= 0) // merges arrays if they both contain data
{
$friends = array_merge($userreqarray, $userfriendarray);
$friend1 = array_rand($friends);
}
elseif ($userreqarray != 0)
{
var_dump ($userreqarray);
foreach($userreqarray as $userreq2);
{
echo "$userreq2";
}
}
elseif($userfriendarray != 0)
{
foreach($userfriendarray as $req5 => $reqno) // there is one entry in the table yet this returns 2 values? i dont know why?
{
echo "$reqno";
}
}
echo '<br></center></a></div>';
?>