almightyegg Posted January 2, 2007 Share Posted January 2, 2007 Is there a way to put my two whiles together, I was thinking it would be easier for pagination then.[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;//unrelated code hereecho "<br><br>";while($friendslot1 = mysql_fetch_array($friendcount1)){$friendmain = $friendslot1[friendid2];$f1 = "SELECT * FROM users WHERE id = '$friendmain' LIMIT 1";$f2 = mysql_query($f1);$play = mysql_fetch_assoc($f2);echo "<a href='viewprofile.php?id=$play[id]'><img src='$play[avatar]' border='0' height='85' width='85'><br>$play[firstn] $play[lastn]</a><br><br>";}while($friendslot2 = mysql_fetch_array($friendcount2)){$friendmain2 = $friendslot2[friendid];$f3 = "SELECT * FROM users WHERE id = '$friendmain2' LIMIT 1";$f4 = mysql_query($f3);$play2 = mysql_fetch_assoc($f4);echo "<a href='viewprofile.php?id=$play2[id]'><img src='$play2[avatar]' border='0' height='85' width='85'><br>$play2[firstn] $play2[lastn]</a><br><br>";}?>[/code]Also is there any tutorials anyone knows of for pagination...apart from the phpfreaks ones. They make no sense to me :-X Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/ Share on other sites More sharing options...
almightyegg Posted January 2, 2007 Author Share Posted January 2, 2007 bumping to the top :) Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-151614 Share on other sites More sharing options...
almightyegg Posted January 2, 2007 Author Share Posted January 2, 2007 could it be done like:[code=php:0]$friendslist = $friendcount1+$friendcount2;while($friendidloop = mysql_fetch_array($friendslist)){$friendmain = $friendidloop[id];$f1 = "SELECT * FROM users WHERE id = '$friendmain' LIMIT 1";$f2 = mysql_query($f1);$play = mysql_fetch_assoc($f2);echo "<a href='viewprofile.php?id=$play[id]'><img src='$play[avatar]' border='0' height='85' width='85'><br>$play[firstn] $play[lastn]</a><br><br>";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-151675 Share on other sites More sharing options...
sasa Posted January 2, 2007 Share Posted January 2, 2007 try[code]$sql = "SELECT users.id AS id, users.avatar AS avatar, users.firstn AS firstn, users.lastn AS lastn FROM friends LEFT JOIN users on users.id=IF(friendid = '$GET',friendid2,friendid) WHERE friendid = '$GET' OR friendid2 = '$GET'"$result = mysql_query($sql);while ($play = mysql_fetch_assoc($result) echo "<a href='viewprofile.php?id=$play2[id]'><img src='$play2[avatar]' border='0' height='85' width='85'><br>$play2[firstn] $play2[lastn]</a><br><br>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-151727 Share on other sites More sharing options...
almightyegg Posted January 3, 2007 Author Share Posted January 3, 2007 no luck :( It had several errors which i managed to sort but it didn't display any results :( Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-152163 Share on other sites More sharing options...
sasa Posted January 3, 2007 Share Posted January 3, 2007 sorryi just check query not the rest of codeworking code [code]//$GET=1;//for testing$sql = "SELECT users.id AS id, users.avatar AS avatar, users.firstn AS firstn, users.lastn AS lastn FROM friends LEFT JOIN users on users.id=IF(friendid = '$GET',friendid2,friendid) WHERE friendid = '$GET' OR friendid2 = '$GET'";$result = mysql_query($sql);while ($play = mysql_fetch_assoc($result)) echo "<a href='viewprofile.php?id=$play[id]'><img src='$play[avatar]' border='0' height='85' width='85'><br>$play[firstn] $play[lastn]</a><br><br>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-152501 Share on other sites More sharing options...
almightyegg Posted January 14, 2007 Author Share Posted January 14, 2007 yes it worked!! Thanks....now can anyone give me any good sites for pagination please??? i tried phpfreaks ones and they make no sense to me :( Quote Link to comment https://forums.phpfreaks.com/topic/32587-while-and-pagination/#findComment-160515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.