karimali831 Posted August 7, 2010 Share Posted August 7, 2010 Hi I'm looking something simular to this: http://cupaddon.com/index.php?site=halloffame Under the place column, it shows #1 #2 #3 for each row. How can I use php to use this on my table for each row? And please say if this question makes no sense to you. I simply want to use #1 #2 etc for each of my rows for my table. I am using a while loop for my table also. I really appreciate if anyone can help me on this, thanks very much! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 What is your current code. You will only need to add one or two lines of code at most for this. Quote Link to comment Share on other sites More sharing options...
karimali831 Posted August 7, 2010 Author Share Posted August 7, 2010 $getladders = safe_query("SELECT * FROM ".PREFIX."cup_ladders WHERE ID='$laddID'"); if(!mysql_num_rows($getladders)) { echo 'No ladders for '.getplatname($platID).''; }else $ds=mysql_fetch_array(safe_query("SELECT platID FROM ".PREFIX."cup_ladders WHERE ID='$laddID'")); echo ' <table width="100%" bordercolor="'.$border.'"> <tr> <td width="25%" align="left" class="title" colspan="7"> • Standings</td> <td width="25%" align="center" class="title" colspan="3"> <a href="?site=ladders&platID='.$ds['platID'].'"><img border="0" width="16" height=16" src="images/cup/icons/goback.png"> <b>Ladders</b></a> | <a href="?site=matches&laddID='.$laddID.'"><b>Matches</b> <img border="0" width="16" height=16" src="images/cup/icons/goforward.png"></a></td> </tr> <tr> <td width="5%" bgcolor="'.$bg1.'" class="title2" align="center">Rank:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Teamname:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">XP:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Activity:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Won:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Draw:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Lost:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Streak:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Ratio:</td> <td width="10%" bgcolor="'.$bg1.'" class="title2" align="center">Challenge:</td> </tr>'; while($ld=mysql_fetch_array($getladders)) { $laddID = $ld['ID']; if(ladderis1on1($laddID)) { $participants = safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE ladID='$laddID' AND 1on1='1'"); }else $participants = safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE ladID='$laddID' AND 1on1='0'"); while($ds=mysql_fetch_array($participants)) { $teamID = $ds['clanID']; if(ladderis1on1($ds['ladID'])) { echo ' <tr> <td bgcolor="'.$bg1.'" width="5%" align="center">#'.$rank.'</td> <td bgcolor="'.$bg1.'" width="10%" align="center"><a href="?site=profile&id='.$ds['clanID'].'">'.getnickname($ds['clanID']).'</a></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> </tr> <br>'; }else{ echo ' <tr> <td bgcolor="'.$bg1.'" width="5%" align="center">#'.$rank.'</td> <td bgcolor="'.$bg1.'" width="10%" align="center"><a href="?site=clans&action=show&clanID='.$ds['clanID'].'">'.getclanname($teamID).'</a></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> <td bgcolor="'.$bg1.'" width="10%" align="center"></td> </tr> <br>'; } } }echo '</table>'; Have nothing for $rank, that's what I want: $rank = #1, #2 etc Thank you! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 Add $rank = 1; before this line while($ds=mysql_fetch_array($participants)) { $teamID = $ds['clanID']; Now change } } }echo '</table>'; to } $rank++; } }echo '</table>'; Quote Link to comment Share on other sites More sharing options...
karimali831 Posted August 7, 2010 Author Share Posted August 7, 2010 worked perfect, thank you! Quote Link to comment Share on other sites More sharing options...
karimali831 Posted August 20, 2010 Author Share Posted August 20, 2010 Also, am I able to pick this value from each row using a variable? 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.