Hello,

i have managed to get hold of social engine and trying to edit the profile script to create a friends list like facebook instead of it saying i have so many friends,

This is my first time using smarty so im still learning

this is my profile.php

$page_id = $_GET['user'];
$sql = "SELECT * FROM se_friends WHERE friend_user_id1 = '$page_id' AND friend_status = '1' LIMIT 0,9";
$mysql = mysql_query($sql) or die (mysql_error());
$all_friends = array();
$all_info = array();
while ($rows = mysql_fetch_array($mysql))
{ 
	$friend_id = $rows['friend_user_id2'];
	$query = "SELECT * FROM se_users WHERE user_id = '$friend_id'";
	$mysql = mysql_query($query) or die(mysql_error());
	while($get = mysql_fetch_array($mysql)) 
	{
		array_push($all_info, $get);
	}
}

$smarty->assign("friends_list", $all_info);

then profile.tpl

{section name=i loop=$friends_list}
      	<td><img class='photo' src='./images/nophoto.gif' width="50" height="50" align="absmiddle" border='0'><a style="padding-left:5px" href="profile.php?user={$friends_list[i].user_id}">{$friends_list[i].user_displayname}</a></td>
	  {/section}

the first mysql statment works perfectly but the second one is not it only gets one results

Member Avatar for diafol
while($get = mysql_fetch_array($mysql)) 
	{
		array_push($all_info, $get);
	}
}

on a quick look, you're passing an array ($get) to be added to the $all_info array. Is that what you want to do?

yes i thought with all the info in a array it would be alot easier to pass around the loads of variables,

and the tutorials i have seen about loops on smarty has all been with arrays

Member Avatar for diafol

read your post again - and noticed the smarty loop - yeah ok .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.