在两个 HTML 表之间添加运输 Returns

Add Carriage Returns Between Two HTML Tables

我有以下语法为我生成和创建两个 table。我遇到的问题是顶部 table 直接位于底部 table 之上。我想在两者之间添加一个 "buffer" 的白色 space。我尝试执行如下所示的 echo "<br><br>";,但要么是我将它放在错误的位置,要么是语法不正确。有人可以告诉我如何在两个 html table 之间添加 space 吗?

    {source}
<html>
<?php
$option = array();
$option['driver'] = 'mssql';
$option['host'] = '192.555.24.24';
$option['user'] = 'username';
$option['password'] = 'password';
$option['database'] = 'data';
$option['prefix'] = '';
$db = JDatabase::getInstance($option);
$sql = $db->getQuery(true);
$sql = "SELECT Query One";
$db->setQuery($sql);
$sql = $db->loadObjectList();
?>
<body>
<form method="POST">
Select a ranger:
<select name="ranger" id="ranger">
<option selected="selected">All</option>
<?php 
foreach ($sql as $name) 
{ 
?>
<option value="<?= $name->rangerName ?>"><?= $name->rangerName ?></option>
<?php 
}
;?>
</select>
D1:<input type="date" name="d1" value="<?= $_POST['d1'] ?>">
D2:<input type="date" name="d2" value="<?= $_POST['d2'] ?>">
<input type="submit" name="submit" value="Get Info">
</form>
</body>

<?php
if (isset($_POST['submit'])) 
{
$d1error = false;
$d2error = false;
if (empty($_POST['d1'])) 
{
$d1error = true;
}
if (empty($_POST['d2'])) 
{
$d2error = true;
}
if ($d1error)
{
echo "<strong>Please select a start date.</strong><br>";
} else if ($d2error) 
{
echo "<strong>Please select a end date.</strong><br>";
} else 
{
$d1 = $_POST['d1'];
$d2 = $_POST['d2'];
$rangername = $_POST['ranger'];

$option = array();
$option['driver'] = 'mssql';
$option['host'] = '192.555.24.24';
$option['user'] = 'username';
$option['password'] = 'password';
$option['database'] = 'data';
$option['prefix'] = '';
$db = JDatabase::getInstance($option);
$query11 = $db->getquery11(true);
$query11 = "Select Query 2";
}
$db->setquery($query11);
$query11 = $db->loadObjectList();
if ($query11) 
{
?>
<table border="1">
<thead>
<tr>
<th>Header 1 </th>
<th>Header 2 </th>
<th>Header 3) </th>
</tr>
</thead>
<?php
echo "<br><br><br><br>";
foreach ($query11 as $res) 
{
print "<tr>";
print "<td>" . "$" . round($res->field1) . "</td>";
print "<td>" . "$" . round($res->field2) . "</td>";
print "<td>" . "$" . round($res->field3) . "</td>";
print "</tr>";
}
}
$query = $db->getQuery(true);
}
$query = "Select Query";
$db->setQuery($query);
$query = $db->loadObjectList();
if ($query) 
{
?>
<table border="1">
<thead>
<tr>
<th>field1 </th>
<th>field2 </th>
<th>field3 </th>
<th>field4 </th>
<th>field5 </th>
<th>field6 </th>
<th>field7 </th>
<th>field8 </th>
</tr>
</thead>
<?php
foreach ($query as $res) 
{
print "<tr>";
print "<td>" . $res->field1 . "</td>";
print "<td>" . "$" . round($res->field2) . "</td>";
print "<td>" . "$" . round($res->field3) . "</td>";
print "<td>" . $res->field4 . "</td>";
print "<td>" . $res->field5 . "</td>";
print "<td>" . $res->field6 . "</td>";
print "<td>" . $res->field7 . "</td>";
print "<td>" . $res->field8 . "</td>";

print "</tr>";
}
} 
else 
{
echo "<strong>$rangername has no data to show for the date range of $d1 to $d2 .</strong>";
}
?>
</table>
</html>
{/source}

br 标签位置错误,您应该将它们放在第一个 table 标签之后,紧跟在第一个 </table> 标签之后(现在已丢失)

但更好的方法是使用 css 为 table 之一添加边距 你可以先试试这个 table

<table style="margin-bottom: 10px;">