【发布时间】:2021-11-21 15:02:42
【问题描述】:
我想将 json 输出显示到 html 表,但该表有很多空记录。 (下图)
<?php
$json2=file_get_contents("****" . $row["Kenteken2"]);
$data2 = json_decode($json2);
if (strpos($data2[0], 'model') !== false) {
echo '<h4>Zelfde serie voertuigen</h4>';
// Open the table
echo '<table class="GeneratedTable">';
echo '<thead><tr><th>Niet DB</th><th>In DB</th></tr></thead><tbody><col style="width:50%" span="2" />';
// Cycle through the array
foreach ($data2 as $vrt) {
// Output a row
echo '<tr>';
echo '<td><a href="/****.php?ktk='.$vrt->model.'&via=ktk.net/'.$row["Kenteken2"].'&model='.$row["MerkModel"].'" target="_blank">'.$vrt->model .'</a></td>';
echo '<td><a href="/****.php?ID='.$vrt->id.'">'.$vrt->model2 .'</a> '.$vrt->dienst . ' ' . $vrt->bijzonderheden .'</td>';
echo "</tr>";
}
// Close the table
echo "</tbody></table>";
}
?>
结果:
【问题讨论】:
-
你能扩展一下这个问题吗?我实际上不确定你在问什么。
-
对不起,问题是行之间
有空行。我想删除这个空行。 当在“In DB”处具有值时,您会在标题“Niet DB”下看到空行。我想在表中删除这个空行。所有的文字都很好。所以你想要一列从上到下列出数据库中的值,一列列出不存在的值,你不关心这意味着一行将包含两条记录彼此没有任何关系?对不起,我想要 2 列。但里面没有空行。
标签: php html json html-table