简体   繁体   English

如何在PHP的表格中设置单元格的innerHTML?

[英]How can I set the innerHTML of cells in a table in PHP?

The website I'm trying to create uses a database and I put the values into an array. 我尝试创建的网站使用数据库,并将值放入数组中。 I made a table with the tds having numberic ids (from 1 to 12) and I want to put the values received from sql query to the corresponding cells. 我用一个具有数字ID(从1到12)的tds制成了一个表,我想将从sql查询中接收到的值放入相应的单元格中。 This is the code that I wrote. 这是我编写的代码。 Alerting works but not the innerHTML. 警报有效,但innerHTML无效。 (It's inside PHP as it gets called if a submit button is set.) (如果设置了提交按钮,它将在PHP内被调用。)

$i=1;
print "<script type=\"text/javascript\">";
for($i=1;$i<=12;$i++){
$bev_temp = $bev[$i-1];
print "alert($bev[0]);";
print "document.getElementById($i).innerHTML = $bev_temp;";
}
print "</script>";
print "document.getElementById($i).innerHTML = '$bev_temp';";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM