Hi,
I am using this coding to display the list of friends the user has. The friends are listed with their username and images.
- Is the code is the good one to display the list of friends.
- From the list of friends, when the username is clicked it takes to the profile page, i also want that to be worked when i click the image also. How to set anchor tag in images.
Code:
<?PHP
session_start();
$userid = $_SESSION['loggeduser'];
require_once('../include/DBConnect.php');
$query = "select friend from friends where userid='$userid';";
$result = mysql_query($query);
if(mysql_num_rows($result) < 1)
{
echo "No Friends for users" ;
}
echo "<table border=\"0\" >";
echo "<tr>";
while($friendid = mysql_fetch_array($result,MYSQL_ASSOC))
{
$friendid = $friendid['friend'];
$query = "select id,username from tbl_users where id='$friendid';";
$result1 = mysql_query($query);
$userdata = mysql_fetch_array($result1,MYSQL_ASSOC);
$username = $userdata['username'];
$userid = $userdata['id'];
$userimg = "photos/avatar/".$friendid."/".$friendid.".jpg";
echo "<td>";
echo "<table border=\"1\">";
echo "<tr>";
echo "<td>";
echo "<img src=\"$userimg\" alt=\"\" width=\"100px\" height=\"125px\" >";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\">";
echo "<a href=\"home.php?p=64&u=$userid\">$username</a>";
echo "</tr>";
echo "</td>";
echo "</table>";
echo "</td>";
}
echo "</tr>";
echo "</table>";
?>