karimali831 Posted July 31, 2012 Share Posted July 31, 2012 Hi all, Would anyone be able to point me in the right direction in using php to create html tables, for instance this is a lower bracket for a 8/16 tournament-tree and trying to find a way to use php to create this table for 32+ brackets. This is 8:- http://teamx1.com/lbracket8.html <table align="center" cellpadding="2" cellspacing="0" width="100%"> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan27">$clan[27]</select></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan21">$clan[21]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[11]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan25">$clan[25]</select></td> <td style="border-right:2px solid #000000;" align="center">$match[14]</td> <td bgcolor="#efefef" align="center"><select name="lb_winner" onChange="change_clan(this.value, 'clan16')">$clan[lb_winner]</select></td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan17">$clan[17]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[9]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan22">$clan[22]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan18">$clan[18]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[13]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan28">$clan[28]</select></td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan19">$clan[19]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[10]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan23">$clan[23]</select></td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan20">$clan[20]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[12]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan26">$clan[26]</select></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan24">$clan[24]</select></td> <td> </td> <td> </td> <td> </td> </tr> </table> And 16: http://teamx1.com/lbracket.html <table align="center" cellpadding="2" cellspacing="0" width="100%"> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan59">$clan[59]</select></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan53">$clan[53]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan41">$clan[41]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[21]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan49">$clan[49]</select></td> <td style="border-right:2px solid #000000;" align="center">$match[27]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan57">$clan[57]</select></td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan33">$clan[33]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[17]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan42">$clan[42]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan34">$clan[34]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;" align="center">$match[30]</td> <td bgcolor="#efefef" align="center"><select name="lb_winner" onChange="change_clan(this.value, 'clan32')">$clan[lb_winner]</select></td> </tr> <tr> <td> </td> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[25]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan54">$clan[54]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan35">$clan[35]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[18]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan43">$clan[43]</select></td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan36">$clan[36]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center"> $match[22] </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan50">$clan[50]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan44">$clan[44]</select></td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[29] </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan60">$clan[60]</select></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan45">$clan[45]</select></td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[23]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan51">$clan[51]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan37">$clan[37]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[19]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan46">$clan[46]</select></td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan38">$clan[38]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td style="border-right:2px solid #000000;" align="center">$match[26]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan55">$clan[55]</select></td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan39">$clan[39]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td style="border-right:2px solid #000000;" align="center">$match[20]</td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan47">$clan[47]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan40">$clan[40]</select></td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;" align="center"> $match[24] </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan52">$clan[52]</select></td> <td style="border-right:2px solid #000000;" align="center">$match[28]</td> <td style="border-right:2px solid #000000;" bgcolor="#efefef" align="center"><select name="clan58">$clan[58]</select></td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan48">$clan[48]</select></td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td style="border-right:2px solid #000000;"> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan56">$clan[56]</select></td> <td> </td> <td> </td> <td> </td> </tr> </table> Possible to be done? Quote Link to comment Share on other sites More sharing options...
Jessica Posted July 31, 2012 Share Posted July 31, 2012 You would need to use loops. Beyond that, it's just a matter of echoing the HTML. Have you tried any code yet? Quote Link to comment Share on other sites More sharing options...
karimali831 Posted July 31, 2012 Author Share Posted July 31, 2012 I do not want to echo the whole table I want to use php to dynamically generate the rows/columns (tr's td's) based on the structure. I know loops must be used but not sure how to do this :s Quote Link to comment Share on other sites More sharing options...
Jessica Posted July 31, 2012 Share Posted July 31, 2012 In your examples, I think you have the brackets set up incorrectly anyway. Look at these images and compare them to your pictures. They don't look right. https://www.google.com/search?q=16+team+bracket&hl=en&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=-_AXUM-RA4q68AH06IGgCA&ved=0CFcQsAQ&biw=1280&bih=655 https://www.google.com/search?q=8+team+bracket&hl=en&prmd=imvns&tbm=isch&tbo=u&source=univ&sa=X&ei=-_AXUM-RA4q68AH06IGgCA&ved=0CFcQsAQ&biw=1280&bih=655 Quote Link to comment Share on other sites More sharing options...
Jessica Posted July 31, 2012 Share Posted July 31, 2012 Here's how an 8 team bracket looks to me, this is without any formatting. <?php $teams = 8; $levels = 1; $numTeams = 2; $matches = array(); do{ $matches[$levels] = $numTeams; $numTeams *= 2; $levels++; } while($numTeams <= $teams); $matches = array_reverse($matches); echo '<table> <tr>'; foreach($matches AS $level=>$numMatches){ echo '<td>'; for($i=1; $i<=$numMatches; $i++){ echo 'Team A vs Team B<br>'; } echo '<td>'; } echo '</tr> </table>'; ?> Quote Link to comment Share on other sites More sharing options...
karimali831 Posted July 31, 2012 Author Share Posted July 31, 2012 Thanks for your help, should of explained I am trying to do this for the lower/loser bracket, so the loser in upper bracket drops down to lower bracket. If you take a look here:- http://teamx1.com/popup.php?site=test&action=brackets You will notice the upper bracket is fine but the lower bracket is not and should have the structure of http://teamx1.com/lbracket8.html http://teamx1.com/lbracket.html Upper bracket is more straightforward but lower bracket I am having problems. Hope you can help me on this. 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.