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 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名