IamHe
03-19-2009, 06:48 PM
I made this script, the idea was to showa user theyer friends.
it successfully echos your number of friends.
but the problem im having is , it only echos the first row.
so its only showing your first friend, going by id.
so it could say, you have six friends, yet only show you one.
i cant figure it out.
probally a stupid mistake.
any ideas?
thanks allot
<?
session_start();
include ('dbc.php');
include ('functions.php');
?>
<?php if (isset($_SESSION['user'])) { ?>
<?
$sql = 'SELECT * FROM `friends` WHERE `friend` = "'.$_SESSION['user'].'" ORDER BY id ASC LIMIT 15 ';
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
if ($num > 0)
{
echo "You Currently have", $num," friends<br /><br /><br />";
}
else
{
echo "You Currently Have No Friends.";
}
?>
<?
$sql = 'SELECT * FROM `friends` WHERE `friend` = "'.$_SESSION['user'].'" ORDER BY id ASC LIMIT 15 ';
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$sql2 = 'SELECT * FROM `users` WHERE `username` = "'.$row['befriended'].'" ORDER BY id ASC LIMIT 15 ';
$result2 = mysql_query($sql2) or die (mysql_error());
$row2 = mysql_fetch_array($result2);
if ($num > 0)
{
echo "<img src=\"",$row2['defaultpic']," \" width=\"85\" height=\"110\" />","<br />",$row['befriended'] ;
}
?>
<? } ?>
it successfully echos your number of friends.
but the problem im having is , it only echos the first row.
so its only showing your first friend, going by id.
so it could say, you have six friends, yet only show you one.
i cant figure it out.
probally a stupid mistake.
any ideas?
thanks allot
<?
session_start();
include ('dbc.php');
include ('functions.php');
?>
<?php if (isset($_SESSION['user'])) { ?>
<?
$sql = 'SELECT * FROM `friends` WHERE `friend` = "'.$_SESSION['user'].'" ORDER BY id ASC LIMIT 15 ';
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
if ($num > 0)
{
echo "You Currently have", $num," friends<br /><br /><br />";
}
else
{
echo "You Currently Have No Friends.";
}
?>
<?
$sql = 'SELECT * FROM `friends` WHERE `friend` = "'.$_SESSION['user'].'" ORDER BY id ASC LIMIT 15 ';
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$sql2 = 'SELECT * FROM `users` WHERE `username` = "'.$row['befriended'].'" ORDER BY id ASC LIMIT 15 ';
$result2 = mysql_query($sql2) or die (mysql_error());
$row2 = mysql_fetch_array($result2);
if ($num > 0)
{
echo "<img src=\"",$row2['defaultpic']," \" width=\"85\" height=\"110\" />","<br />",$row['befriended'] ;
}
?>
<? } ?>