Give the following a try. I haven't tested the below.
$sql_string = "insert into friends_table(friend_id,friend_name) values";
$insertValues = array();
$friends_list_array = json_decode(....)['data'];
foreach($friends_list_array as $friends){
$insertValues[] = "({$friend['id']}, {$friend['name']})";
}
if (mysql_query($sql_string . implode(",", $insertValues) . ";")){
//added all the data..
}else{
//some error..
}
PS: Issues pointed out by Kolink are very valid. There may be some other way out for what you are doing.
UPDATE:
If you need to store all the ids of your friends in a single field (which is actually a bad idea, see below), then you have to serialize the friends-list-data (may be) using JSON, and store it as a string.
$friends_list_array = json_decode(....)['data'];
$friends_id = array_map(function($friend){ return $friend['id'];},$friends_list_array);
$friends_list_json = json_encode($friends_id);
if (mysql_query("insert into friends_table(user, friends) values ('$curUserId','$friends_list_json';")){
//added all the data..
}else{
//some error..
}
Storing a serialized data in a single field is actually a bad idea, unless you are accessing/modifying the entire list all at once. Better option would be spreading the data across rows.