duandu1966 2017-06-26 16:50
浏览 48
已采纳

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

I have the following syntax which generates and creates two tables for me. The issue that I have is that the top table is directly on top of the bottom table. I would like to add in a "buffer" of white space between the two. I tried to do echo "<br><br>"; as you see below, but either I placed it in the wrong location or that is not the correct syntax. Can someone show me how to add space between the two html tables?

    {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条回答 默认 最新

  • duanmei1946 2017-06-26 17:00
    关注

    The br tags are in wrong place you should put them after the first table and its just after the first </table> tag (which is missing now)

    But a better aproach would be adding a margin to one of tables using css You can try this one for the first table

    <table style="margin-bottom: 10px;">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 QQ邮箱过期怎么恢复?
  • ¥15 登录他人的vue项目显示服务器错误
  • ¥15 (标签-android|关键词-app)
  • ¥60 如何批量获取json的url
  • ¥15 comsol仿真压阻传感器
  • ¥15 Python线性规划函数optimize.linprog求解为整数
  • ¥15 llama3中文版微调
  • ¥15 pg数据库导入数据序列重复
  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)