我正在尝试制作一个有标题的表格: 摘要声明截至2017年8月3日12:55
使用js的日期适用于其他地方,但不适用于此。这有诀窍吗?我正在使用php / mysql查询来获取其余的数据。
echo "<table class='table table-bordered table-striped table-nonfluid'>";
echo "<thead>";
echo "<tr>";
echo "<th colspan ='2'>Summary Statement as at <span id= "date"></span></th>";
echo "</tr>";
JS:
<script>
document.getElementById("date").innerHTML = Date().slice(3,25);
</script>
修订:
echo "<table class='table table-bordered table-striped table-nonfluid'>";
echo "<thead>";
echo "<tr>";
echo "<th colspan ='2'>Summary Statement as at <span id='date'></span></th>";
echo "</tr>";
echo "<thead>";
echo "<tr>";
echo "<th>Payments</th>";
echo "<th>Amount (R)</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = $result->fetch_array()){
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
答案 0 :(得分:1)
您在id属性周围使用了错误的引号。我通常使用&#39;对于outers和&#34;对于内心。尝试将日期周围的引号更改为单引号。
答案 1 :(得分:1)
试试吧
echo "<table class='table table-bordered table-striped table-nonfluid'>";
echo "<thead>";
echo "<tr>";
echo "<th colspan ='2'>Summary Statement as at <span id= 'date'></span></th>";
echo "</tr>";
答案 2 :(得分:0)
你回应错误的行:) echo“摘要声明”;
因为span id是echo的一部分,它应该有''引号而不是“”,就像colspan属性一样。