【发布时间】:2013-07-07 11:07:30
【问题描述】:
我有 10*10 的固定表,可以打印两个 for 循环。
一些图像显示在一些给定的table cell 中,与管理员给定的行 ID 和列 ID 匹配。
$table .= '<table border="1" cellspacing="0" cellpadding="2" class="banner_table">';
for($x=1; $x<=10; $x++) {
$table .= "<tr>";
for($y=1; $y<=10; $y++) {
$table .= "<td class='thumbnail'>";
if (isset($temp[$x][$y])) {
$count++;
$table .= "<a target='_blank' href='" . ($temp[$x][$y]['img_url'] ? $temp[$x][$y]['img_url'] : "#") . "'>
<img id='imgid' src='admin/small-image/" . $temp[$x][$y]['img_title'] . "' width='20' height='20' /></a>";
}
else $table .=" ";
$table .= "</td>";
}
$table .= "</tr>";
}
$table .= '</table>';
如果没有给出row id 和column id,我应该如何为表格单元格提供索引号,例如 1,2,2...?我想同样给出索引号 1(ROW 1 和 COL1),索引号 2(ROW1 和 COL2)。
是否有任何方法可以从行 ID 和列 ID 获取表格单元格编号?
【问题讨论】:
标签: php html arrays for-loop html-table