Jump to content

[SOLVED] while problems


almightyegg

Recommended Posts

i have a table of friends set out like this:
id (primary key)  1  2
friendid              1  8
friendid2            2  406
or whatever it maybe and i have a page listing all friends (where your id is friendid) except it counts the rows, but doesnt list the friends name....
[code=php:0]
<?
$friendcount1 = mysql_query("SELECT * FROM friends WHERE friendid = '$GET'");
$friends1 = mysql_num_rows($friendcount1);
$friendcount2 = mysql_query("SELECT * FROM friends WHERE friendid2 = '$GET'");
$friends2 = mysql_num_rows($friendcount2);
$friends = $friends1+$friends2;
?>
You have <?
echo "$friends ";
if($firends > 1){
echo "friends:";
}elseif($friends == 0){
echo "friends! Go get some now!!!!";
}else{
echo "friend:";
}

while($friendslot1 = mysql_fetch_array($friendcount1)){
$friendslot1[friendid2] = $friendmain;
$f1 = "SELECT * FROM users WHERE id = '$friendmain' LIMIT 1";
$f2 = mysql_query($f1);
$play = mysql_fetch_assoc($f2);
echo "$play[firstn] $play[lastn]";
}
?>
[/code]
Link to comment
Share on other sites

Your $_GET is missing some info... it should look like

$_GET['XXX'];


it is the ?XXX=somedata piece of the puzzle.

$_GET is passing Array into your query, as $_GET[] is an array if you echo your query right below where you run it, I am sure you will see WHERE friendid='Array' same for the second one

Link to comment
Share on other sites

should'nt this:
[code=php:0]
$friendslot1[friendid2] = $friendmain;
[/code]

be this:
[code=php:0]
$friendmain = $friendslot1[friendid2];
[/code]

and what is $GET at the top, what have you defined it as. and change your echo down the botom to loook like this:

[code=php:0]
echo $play['firstn']." ".$play['lastn'];
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.