php - For loop to create extra columns -


this code displays basic tree structure bracket, trying complete following:-

  1. where shows:

    style="border-right:2px solid #000;"

    i trying use border every row, script not create rows in between teams/seeds define border, trying show border-right every row every team 1 team 2 etc , other rounds team 1 team 2 etc.

  2. php error reporting returning following line has undefined offset after } else {?

    $line[$i] .= '<td align="center" style="border-right:2px solid #000;" colspan="2">vs</td>'; 

    3.

            $array = array('team 1', 'team 2', 'team 3', 'team 4', 'team 5', 'team 6', 'team 7', 'team 8');         $j = count($array);         ($a=0; pow(2, $a) <= $j; $a++) //determine highest power of 2 go array count         {             $y[$a] = 1;             $maxpower = $a;         }         ($i=1; $i < $j*2; $i++)         {             if($i % 2 != 0) //odd number rows teams             {                 $line[$i] = '<td class="pf_title_bg" style="border-right:2px solid #000;">' . $array[($i-1)/2] . '</td>                              <td class="pf_content_bg" style="border-right:2px solid #000;">&nbsp;</td>';             }             else             {                  for($b=0; $b<=$maxpower; $b++)                 {                      $round = $b+1;                                   $line2[$b] = ($b < $maxpower ? "<th colspan='2'>round {$round}</th>" : "<th colspan='2'>winner</th>");                      if($i % pow(2, $b) == 0) //even rows future rounds. every 2^1 rows first winner, 2^2 second winner, 2^3 third , on.                     {                         if($i % pow(2, $b+1) != 0) //does not divide next power of 2, must last available cell                         {                             $line[$i] .= '<td class="pf_title_bg" style="border-right:2px solid #000;">team '.$b.'_'.($y[$b]++).'</td>                                           <td class="pf_content_bg" style="border-right:2px solid #000;">&nbsp;</td>';                         }                         else //the input added in future round                         {                             $line[$i] .= '<td align="center" style="border-right:2px solid #000;" colspan="2">vs.</td>';                         }                     }                 }             }         }             //name="win'.$b.'_'.($y[$b]++).'                          eval ("\$content = \"".$this->gettemplate("table_header")."\";");          $content.="<thead><tr>";          foreach($line2 $col)          {             $content.=$col;         }          $content.="</tr></thead>";          foreach($line $row)         {             $content.="<tbody><tr>{$row}</tr></tbody>";         }          eval ("\$content.= \"".$this->gettemplate("table_footer")."\";"); 

any on appreciated

you aren't constructing table correctly; putting tbody tag around every row, invaliding html. works me:

<?php $array = array('team 1', 'team 2', 'team 3', 'team 4', 'team 5', 'team 6', 'team 7', 'team 8');             $j = count($array);             ($a=0; pow(2, $a) <= $j; $a++) //determine highest power of 2 go array count             {                 $y[$a] = 1;                 $maxpower = $a;             }             ($i=1; $i < $j*2; $i++)             {                 if($i % 2 != 0) //odd number rows teams                 {                     $line[$i] = '<td class="pf_title_bg" style="border-right:2px solid #000;">' . $array[($i-1)/2] . '</td>'.php_eol.'<td class="pf_content_bg" style="border-right:2px solid #000;">&nbsp;</td>'.php_eol;                 }                 else                 {                      for($b=0; $b<=$maxpower; $b++)                     {                          $round = $b+1;                         $line2[$b] = $b < $maxpower ? "<th colspan='2'>round {$round}</th>".php_eol : "<th colspan='2'>winner</th>".php_eol;                          if($i % pow(2, $b) == 0) //even rows future rounds. every 2^1 rows first winner, 2^2 second winner, 2^3 third , on.                         {                             if($i % pow(2, $b+1) != 0) //does not divide next power of 2, must last available cell                             {                                 $line[$i] .= '<td class="pf_title_bg" style="border-right:2px solid #000;">team '.$b.'_'.($y[$b]++).'</td>'.php_eol.'<td class="pf_content_bg" style="border-right:2px solid #000;">&nbsp;</td>';                             }                             else //the input added in future round                             {                                 $line[$i] .= '<td align="center" style="border-right:2px solid #000;" colspan="2">vs.</td>'.php_eol;                             }                         }                     }                 }             }              //name="win'.$b.'_'.($y[$b]++).'              //eval ("\$content = \"".$this->gettemplate("table_header")."\";");              $content="<table><thead><tr>";              foreach($line2 $col)             {                 $content.=$col;             }              $content.="</tr></thead><tbody>".php_eol;              foreach($line $row)             {                 $content.="<tr>{$row}</tr>".php_eol;             }              $content.='</tbody></table>';              //eval ("\$content.= \"".$this->gettemplate("table_footer")."\";");             echo $content;  ?> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -