Page 1 of 1

Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 8:36 am
by radium35
This only spits out 1 user information but there are many that fit that description and the while loop before displays all users fine just when i want to go to another table and retrieve profile information it only shoots out 1 :banghead: :crazy:


<?


//FRIENDS PAGE


if (!$link = mysql_connect('--', '--', '--')) {
echo 'Could not connect to mysql';
exit;
}

if (!mysql_select_db('modelsite', $link)) {
echo 'Could not select database';
exit;
}


$sql = "SELECT * FROM friend_requests WHERE recipient = 'jason' and approved = 'Yes' OR sender = 'jason' and approved = 'Yes' ORDER BY id DESC";

$result = mysql_query($sql, $link);

if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}

while ($row = mysql_fetch_assoc($result)) {

//removes self from friends list

if ( $row['recipient'] == "jason" ) echo NULL; else $recfiltered = $row['recipient'];
if ( $row['sender'] == "jason" ) echo NULL; else $senfiltered = $row['sender'];


}

mysql_free_result($result);


?>
<?

//GET THEIR PROFILE INFO OF OUTPUT USERNAMES

if (!$link = mysql_connect('---', '--', '--')) {
echo 'Could not connect to mysql';
exit;
}

if (!mysql_select_db('modelsite', $link)) {
echo 'Could not select database';
exit;
}



$sql = "SELECT * FROM members WHERE username = '$recfiltered'";
$result = mysql_query($sql, $link);

if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}

while ($row = mysql_fetch_assoc($result)) {

echo $username=$row['username'];

}

mysql_free_result($result);


?>

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 8:47 am
by radium35
should I just have 1 while loop?

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 9:04 am
by radium35
In other words what i want to do is get values from friend_request table and use those values that are usernames to pull out their profile information from members table

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 12:12 pm
by kaszu

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 7:26 pm
by radium35
elaborate, thought this was a forum to get help not to point people to manuals they have read already

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 9:04 pm
by jackpf
Demands will get you nowhere.

Re: Getting All users Info From table from preceding while loop

Posted: Sat Jul 18, 2009 9:24 pm
by califdon
radium35 wrote:elaborate, thought this was a forum to get help not to point people to manuals they have read already
It's pretty much just the opposite. Especially when people asking for help haven't bothered to read the forum's rules, post properly and show a little courtesy.

Re: Getting All users Info From table from preceding while loop

Posted: Sun Jul 19, 2009 9:36 am
by radium35
asking for help is demanding? what planet do you live on? MARS anyways to those who KNOW I would like help thanks

Re: Getting All users Info From table from preceding while loop

Posted: Sun Jul 19, 2009 9:37 am
by radium35
califdon wrote:
radium35 wrote:elaborate, thought this was a forum to get help not to point people to manuals they have read already
It's pretty much just the opposite. Especially when people asking for help haven't bothered to read the forum's rules, post properly and show a little courtesy.
right, I understand why you are jaded but this is not the case here... that could be a possibility right? :banghead: