php + facebook图搜索朋友列表

I retrieve list of user's friends with fb php sdk. Then when my user is typing in inputbox and I would like to show him friends which contains typed letters in separate div according to typing (I think the best way is with javascript). Something like ajax prediction search box but in my case I have users "preloaded" with fb php sdk. Can you please help me how/where should I start to do it? thanks.

First you need to get friends list of user using you API

$user_friends = $facebook->api('/me/friends');
$friends_details = json_decode(file_get_contents('https://graph.facebook.com/me/friends?access_token=<your access token>']), true);

Then you should insert everything into your DB,

for($i=0;$i<sizeof($friends_details);$i++){
   $friend_id = $friends_details['data'][$i]['id'];
   $friend_name = $friends_details['data'][$i]['name'];
}

Now complete it with your sql query.

And Finally you can make a ajax call when user searches for friends name to display it in separate div.