fLaVV Posted December 16, 2007 Share Posted December 16, 2007 What I am trying to do is display members that are in a certain group from my phpbb (group is clan members) and display them in my roster.php file. My script is working fine and displaying the information that I want it to...but for some reason it isn't looping. It is only displaying the first result. Below is the code, sadly this is the only way I know how to do this, so if you guys know of a better way...im open for ideas. <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center"><strong>Username:</strong></td> <td align="center"><strong>Email:</strong></td> <td align="center"><strong>Rank:</strong></td> </tr> <? $connection = mysql_connect("localhost","username","password"); mysql_select_db("database"); $urfcheck = mysql_query("SELECT * FROM phpbb_user_group WHERE group_id = '12'"); while ($row = mysql_fetch_array($urfcheck)){ $user = $row['user_id']; } $getrank = mysql_query("SELECT * FROM phpbb_xdata_data WHERE user_id = '$user'"); while ($row = mysql_fetch_array($getrank)){ $rank = $row['xdata_value']; } $grabinfo = mysql_query("SELECT username FROM phpbb_users WHERE user_id = '$user'"); while ($row = mysql_fetch_array($grabinfo)){ $username = $row['username']; echo "<tr> <td align=center>$username</td> <td align=center><a href=forums/profile.php?mode=viewprofile&u=$user>Click Here</a></td> <td align=center>$rank</td> </tr> </table>"; } mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted December 16, 2007 Share Posted December 16, 2007 <?php $findUsers = mysql_query ("SELECT * FROM `tblName`"); while ( $row = mysql_fetch_array ( $findUsers ) ) { echo $row['username']; echo $row['rank']; echo "<br /><br />"; } ?> Quote Link to comment Share on other sites More sharing options...
AntiScourge Posted December 16, 2007 Share Posted December 16, 2007 Your brackets were in the wrong place. Indenting your code always helps with this See below *edit* I did a bad job of indenting, and had to fix the closing table. <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center"><strong>Username:</strong></td> <td align="center"><strong>Email:</strong></td> <td align="center"><strong>Rank:</strong></td> </tr> <? $connection = mysql_connect("localhost","username","password"); mysql_select_db("database"); $urfcheck = mysql_query("SELECT * FROM phpbb_user_group WHERE group_id = '12'"); while ($row = mysql_fetch_array($urfcheck)){ $user = $row['user_id']; $getrank = mysql_query("SELECT * FROM phpbb_xdata_data WHERE user_id = '$user'"); while ($row = mysql_fetch_array($getrank)){ $rank = $row['xdata_value']; } $grabinfo = mysql_query("SELECT username FROM phpbb_users WHERE user_id = '$user'"); while ($row = mysql_fetch_array($grabinfo)){ $username = $row['username']; } echo "<tr> <td align=center>$username</td> <td align=center><a href=forums/profile.php?mode=viewprofile&u=$user>Click Here</a></td> <td align=center>$rank</td> </tr>"; } mysql_close($connection); ?> </table> Quote Link to comment Share on other sites More sharing options...
fLaVV Posted December 16, 2007 Author Share Posted December 16, 2007 o god...it was so simple...thanks...maybe i should stop making quick scripts in notepad and use my php editor *fLaVV blows dust off maguma studio i will try this and post back...thanks for the help. Quote Link to comment Share on other sites More sharing options...
AntiScourge Posted December 16, 2007 Share Posted December 16, 2007 As a further response. Yes there is a better way to do it, however it's been to long since I've done Joins in MySQL to rememeber how to pull all the data in one query... Something like the following may work SELECT phpbb_user_group.user_id, phpbb_xdata_data.xdata_value, phpbb_users.username FROM phpbb_user_group, phpbb_xdata_data, phpbb_users WHERE phpbb_user_group.group_id = 12' and phpbb_user_group.user_id = phpbb_xdata_data.user_id and phpbb_user_group.user_id = phpbb_users.user_id I don't know if that's perfect, and don't ask me to explain it to ya... here's some quick info on Joins http://www.tizag.com/mysqlTutorial/mysqljoins.php Quote Link to comment Share on other sites More sharing options...
fLaVV Posted December 16, 2007 Author Share Posted December 16, 2007 Thanks..it all worked...dunno why i didnt try that, but i will look into the other method...ty for all the info Quote Link to comment 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.