|
|
|
สอบถามเรื่องของการสร้างชื่อกำกับแถวและคอมลัมน์ ในกรณีที่จำนวนแถวและคอลัมน์ไม่จำกัด |
|
|
|
|
|
|
|
Code (PHP)
<?php
$row = 3;
$col = 27;
echo "<table border=1>";
// create column header
echo "<thead>";
echo "<tr>";
for($x = 0; $x <= $col; $x++){
echo "<td>".getNameFromNumber($x)."</td>";
}
echo "</tr>";
echo "</thead>";
// create row
echo "<tbody>";
for($i = 0; $i <= $row; $i++){
echo "<tr>";
for ($c = 0; $c <= $col; $c++) {
echo "<td>Data Rows[".$i."] Columns[".$c."]</td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
function getNameFromNumber($num) {
$numeric = $num % 26;
$letter = chr(65 + $numeric);
$num2 = intval($num / 26);
if ($num2 > 0) {
return getNameFromNumber($num2 - 1) . $letter;
} else {
return $letter;
}
}
?>
|
|
|
|
|
Date :
2014-01-28 09:49:42 |
By :
Nameless |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$row = 3;
$col = 3;
$colname = array(' ','A','B','C','D','E','F','G');
$rowname = array(' ','1','2','3','4','5','6','7');
echo "<table border=1>";
for($i=0;$i<=$row;$i++){
echo "<tr>";
for($x=0;$x<=$col;$x++){
if($i == 0) echo "<td>{$colname[$x]}</td>";
else if($x == 0)
echo "<td>{$rowname[$i]}</td>";
else echo "<td>TEST</td>";
}
echo "</tr>";
}
echo "</table>";
?>
|
|
|
|
|
Date :
2014-01-28 14:13:34 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|