如何为每个将被回显的列添加边距,使它们均匀对齐,即。每行中的每一列应该从前一行开始。
[//(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) - //(忽略此行)]
这是我的代码:
function cnt() {
var inputText = document.getElementById("disp").value;
if (document.getElementById("exclsp").checked) //exclude spaces
{
document.getElementById("result").innerHTML = inputText.split(" ").join("").length + " characters";
}
else //include spaces
{
document.getElementById("result").innerHTML = inputText.length + " characters";
}
}
答案 0 :(得分:1)
最好的办法是使用桌子。查看以下代码。
echo "<table>";
echo "<thead>";
echo "<tr>";
echo "<th>YOUR HEADING 1</th>";
echo "<th>YOUR HEADING 2</th>";
echo "<th>YOUR HEADING 3</th>";
echo "<th>YOUR HEADING 4</th>";
echo "<th>YOUR HEADING 5</th>";
echo "<th>YOUR HEADING 6</th>";
echo "<th>YOUR HEADING 7</th>";
echo "<th>YOUR HEADING 8</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo "<tr>";
echo "<td>";
echo $row['COL 1'];
echo "</td>";
echo "<td>";
echo $row['COL 2'];
echo "</td>";
echo "<td>";
echo $row['COL 3'];
echo "</td>";
echo "<td>";
echo $row['COL 4'];
echo "</td>";
echo "<td>";
echo $row['COL 5'];
echo "</td>";
echo "<td>";
echo $row['COL 6'];
echo "</td>";
echo "<td>";
echo $row['COL 7'];
echo "</td>";
echo "<td>";
echo $row['COL 8'];
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
答案 1 :(得分:0)
# start table
echo '<table border="1">';
echo '<thead>';
echo '<th>'; # start heading
echo '<td>COL 1</td>';
echo '<td>COL 2</td>';
# ... up to 16 columns
echo '</th>'; # end heading
echo '</thead>';
echo '<tbody>';
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
# start row
echo '<tr>'
# add cell ie column
echo '<td>' . $row['COL 1'] . '</td>';
echo '<td>' . $row['COL 2'] . '</td>';
# ... up to 16 columns
# end row
echo '</tr>';
}
echo '</tbody>';
// end table
echo '</table>';