almightyegg Posted January 1, 2007 Share Posted January 1, 2007 i have a table of friends set out like this:id (primary key) 1 2friendid 1 8friendid2 2 406or 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 More sharing options...
chronister Posted January 1, 2007 Share Posted January 1, 2007 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 More sharing options...
JasonLewis Posted January 1, 2007 Share Posted January 1, 2007 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 More sharing options...
almightyegg Posted January 2, 2007 Author Share Posted January 2, 2007 awesome it works!! the $GET was defined earlier, sorry i should have included that. Link to comment https://forums.phpfreaks.com/topic/32487-solved-while-problems/#findComment-151393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.