Jump to content

drawing brackets


glenelkins

Recommended Posts

hi

 

i have spent alot of time working out the math and writing code to generate brackets for a tournament system. The layout i have done with css but personally i think using a table would actually lay it out more accurately and more easily.

 

The problem i have. If you look at the following table in HTML it lays out for 2 players a horizontal bracket:

 

<table>
    <tr>
        <td>PLAYER</td>
        <td rowspan="2">PLAYER</td>
    </tr>
   <tr>
        <td>PLAYER</td>
   </tr>
</table>

 

this is all well and good and you can cearly see how this would work for say 4, 8 , 16 players and so on. But, the issue is im not manually writing the bracket display, it should work with any number of players.

 

Now the problem is, i cant get around my head how i would program in a loop for say 8 players using the table format above, mainly because some <td> tags need rowspans, for example if there are 8 players in the first round, the winner needs rowspan of 8

 

Does anyone follow what im saying? If it was a vertical table, that would be much easier but it has to work horizontal from left to right

Link to comment
https://forums.phpfreaks.com/topic/160369-drawing-brackets/
Share on other sites

If you dont want to involve with loops and checks you can have :

<table>

    <tr>

        <td><table><tr><td>1</td><td>2</td></tr></table></td>

        <td><table><tr><td>3</td></tr></table></td>

    </tr>

</table>

 

i dont know what you need but my idea is to put a base table with the players and show them into a seperate table inside.

 

Link to comment
https://forums.phpfreaks.com/topic/160369-drawing-brackets/#findComment-846317
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.