Javascript 如何内爆每一行并显示在表上?
我想显示Javascript 如何内爆每一行并显示在表上?,javascript,php,html,mysql,Javascript,Php,Html,Mysql,我想显示td标记中每行有多少键和值,但在我的第二个td标记中显示第一行和第二行。。还有第三个 如何显示第一个td标记中的第一行,以及第二个td标记中的第二行?以下是我目前的代码: <table> <thead> <tr> <th>Rows</th> </tr> </thead> <tbody> <?php $query
td
标记中每行有多少键和值,但在我的第二个td
标记中显示第一行和第二行。。还有第三个
如何显示第一个td
标记中的第一行,以及第二个td
标记中的第二行?以下是我目前的代码:
<table>
<thead>
<tr>
<th>Rows</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT from_monday, from_tuesday, from_wednesday,from_thursday, from_friday, to_monday, to_tuesday,to_wednesday, to_thursday, to_friday from tabletest ORDER BY survey_id DESC LIMIT 4";
$result = mysql_query($query, $connection);
if($result === FALSE) { die(mysql_error()); }
while($details = mysql_fetch_array($result))
{
$newArray = array_count_values($details) ;
foreach ($newArray as $key => $value)
{
$newValue = $value/2;
$key = trim(addslashes($key));
$newValue = preg_replace('/\D/', '', $newValue);
$myurl[] = "['".$key."', ".$newValue."]";
}
echo "<tr><td>";
echo implode(",", $myurl);
echo "</td></tr>";
}
?>
</tbody>
</table>
排
您将数据存储在一个数组中,这意味着它在每次循环迭代中也将包含以前的值,您需要在每次迭代中重置数组
$myurl = array();
尝试以下代码
<?php
$query = "SELECT from_monday, from_tuesday, from_wednesday,from_thursday, from_friday, to_monday, to_tuesday,to_wednesday, to_thursday, to_friday from tabletest ORDER BY survey_id DESC LIMIT 4";
$result = mysql_query($query, $connection);
if($result === FALSE) { die(mysql_error()); }
while($details = mysql_fetch_array($result))
{
$newArray = array_count_values($details) ;
$myurl = array();
foreach ($newArray as $key => $value)
{
$newValue = $value/2;
$key = trim(addslashes($key));
$newValue = preg_replace('/\D/', '', $newValue);
$myurl[] = "['".$key."', ".$newValue."]";
}
echo "<tr><td>";
echo implode(",", $myurl);
echo "</td></tr>";
}
?>
自己好好格式化一下。来点好的英语语法怎么样?:-)是否有任何值包含任何HTML?除此之外,我看不出你的代码不起作用的原因。也许试着在第1个td标签[car',5],“train',4],“jeep',1]中发布由代码片段?输出创建的实际HTML输出,但在第2个td标签上显示为“[car',5],“train',4],“jeep',1],“car',6],“train',4]”。。。第一行和第二行显示第二个td标签中的所有内容$newArray=array\u count\u值($details)$myurl=array()代码>试试这个它可以工作。。。谢谢你!我正在尝试将获取的数据放在谷歌饼图中。。。所以我希望我现在能做到。。。