Here is my function to find who is on whos friendlist of my site, it returns a string of friend ID's, it is starting to slow down as my site get larger
Is there anything script wise that could help?
function findfriend() {
$temp = $_SESSION['info'];
$sql_friend = "select userid,friendid,status from friend_friend where userid='$temp[auto_id]' and status='1'";
$result_friend = executeQuery($sql_friend);
while ($line_friend = mysql_fetch_array($result_friend)) {
$friend[] = $line_friend['friendid'];
}
$cnt = count($friend);
if ($cnt > 0) {
$str_friends_ids = implode(",", $friend);
} else {
$str_friends_ids = '';
}
return $str_friends_ids;
}
And here is the table
--
-- Table structure for table `friend_friend`
--
CREATE TABLE IF NOT EXISTS `friend_friend` (
`autoid` int(11) NOT NULL auto_increment,
`userid` int(10) default NULL,
`friendid` int(10) default NULL,
`status` enum('1','0','3') NOT NULL default '0',
`submit_date` datetime NOT NULL default '0000-00-00 00:00:00',
`alert_message` enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (`autoid`),
KEY `userid` (`userid`),
KEY `friendid` (`friendid`),
KEY `alert` (`alert_message`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=505965 ;