在两个HTML表格之间添加回车符

时间:2017-06-26 16:50:59

标签: php html joomla html-table joomla3.0

我有以下语法为我生成并创建两个表。我遇到的问题是顶部表直接位于底部表的顶部。我想添加一个&#34;缓冲区&#34;两者之间的白色空间。如下所示,我尝试echo "<br><br>";,但要么将其放在错误的位置,要么将其放在正确的语法中。有人能告诉我如何在两个html表之间添加空格吗?

    {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}

1 个答案:

答案 0 :(得分:1)

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

但更好的方法是使用css为其中一个表添加一个余量 您可以在第一个表中尝试这个

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