Getting All users Info From table from preceding while loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

Getting All users Info From table from preceding while loop

Post 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);


?>
Last edited by radium35 on Sat Jul 18, 2009 8:51 am, edited 1 time in total.
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

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

Post by radium35 »

should I just have 1 while loop?
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

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

Post 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
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

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

Post by kaszu »

User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

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

Post by radium35 »

elaborate, thought this was a forum to get help not to point people to manuals they have read already
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post by jackpf »

Demands will get you nowhere.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

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

Post 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.
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

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

Post by radium35 »

asking for help is demanding? what planet do you live on? MARS anyways to those who KNOW I would like help thanks
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

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

Post 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:
Locked