【发布时间】:2013-07-23 07:10:42
【问题描述】:
这段代码显示了一个基本的树形结构括号,我正在尝试完成它以现在执行以下操作:-
-
显示位置:
style="border-right:2px solid #000;"
我正在尝试为每一行使用此边框,但此脚本不会在团队/种子之间创建行来定义边框,我正在尝试为每个 TEAM 1 到 TEAM 的每一行显示边框右2 等以及所有其他回合 TEAM 1 到 TEAM 2 等。
-
PHP 错误报告正在返回以下行,在
} 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); for ($a=0; pow(2, $a) <= $j; $a++) //determine the highest power of 2 that will go into the array count { $y[$a] = 1; $maxpower = $a; } for ($i=1; $i < $j*2; $i++) { if($i % 2 != 0) //odd number rows for 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;"> </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 for future rounds. every 2^1 rows for first winner, 2^2 for second winner, 2^3 for third and so on. { if($i % pow(2, $b+1) != 0) //does not divide by the next power of 2, so this must be the 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;"> </td>'; } else //the input will be added in a 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 as $col) { $content.=$col; } $content.="</tr></thead>"; foreach($line as $row) { $content.="<tbody><tr>{$row}</tr></tbody>"; } eval ("\$content.= \"".$this->gettemplate("table_footer")."\";");
非常感谢任何帮助
【问题讨论】:
-
我不确定你使用的权力是否正确; 2^1=2; 2^2=4; 2^3=8 等等...你不想要倍数吗?
-
它似乎工作正常.. 只是想能够添加那些边框?
标签: php arrays loops for-loop html-table