Jump to content

php to create these tables?


karimali831

Recommended Posts

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?

Link to comment
Share on other sites

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>';
?>

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.