Lucky2710 Posted August 11, 2010 Share Posted August 11, 2010 Heres what i got... function printLB1 (){ $result = mysql_query("SELECT * FROM leaderboards ORDER BY CollegeFootballPoints DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->Username; $leaderboardPoints[] = $row->CollegeFootballPoints; } $num = mysql_num_rows($reault); //I know from here to ................... needs to be in a var or echo or something. <tr> <td>1.</td> //This will auto increment too like i++ but i cna do that myself! <td>echo $leaderboard;</td> <td>echo $leaderboardPoints;</td> </tr> //Here......................................................... } I need to pull a table row per user. But i want to somehow do it once in a function and then ill echo the function into a table after the php stuff is done. Like i want to pull every a table row per user in the function. then display the function below that way i don't have to write a whole extra query and table row per person. If you understand please help if not please let me know where i can explain more. Thanks Quote Link to comment Share on other sites More sharing options...
Lucky2710 Posted August 11, 2010 Author Share Posted August 11, 2010 Heres what i did! function printLB1($week){ $weeknum = 'Week'.$week; $result = mysql_query("SELECT * FROM CollegeFootballWeeklyLeaderboards ORDER BY $weeknum DESC"); while ($row = mysql_fetch_object($result)) { $username[] = $row->Username; $leaderboardPoints[] = $row->$weeknum; } $num = mysql_num_rows($result); for($i=0; $i< $num; $i++) { echo ' <tr> <td>'.$i.'.</td> <td>'.$username[$i].'</td> <td>'.$leaderboardPoints[$i].'</td> </tr> '; } } ?> <table width="68%" border="1" cellspacing="0" cellpadding="5"> <tr> <td width="14%"><strong>Position</strong></td> <td width="51%"><strong>User</strong></td> <td width="35%"><strong>Points</strong></td> </tr> <? printLB1(1); ?> </table> 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.