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
https://forums.phpfreaks.com/topic/32487-solved-while-problems/
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
https://forums.phpfreaks.com/topic/32487-solved-while-problems/#findComment-150958
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
https://forums.phpfreaks.com/topic/32487-solved-while-problems/#findComment-150962
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.