我有一个PHP调用,我正在做,并在foreach函数中使用响应来填充表。如何删除PHP响应中的空白?
我的表格单元格包含大量的空白,它看起来像来自于PHP响应。
下面是一个摘录,当您查看TD元素时,可以看到额外的空间。
不知道是什么原因造成这种情况,或者如何删除它,也许修剪?
<div class="container-fluid" style="margin-top:2em;">
<div class="row">
<div class="col-lg-12" style="background: none;">
<h4>Test Drives</h4>
<table class="table table-fixed table-sm table-hover" style="height: 100px; background:pink;">
<thead>
<tr>
<th>
Value
</th>
<th>
Date Submitted
</th>
<th>
User submitted
</th>
<th>
Market
</th>
<th>
Notes
</th>
<th>
Last Update by
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
2 </td>
<td>
2017-03-08 </td>
<td>
ADMIN </td>
<td>
DE </td>
<td>
This is a test </td>
<td>
ADMIN </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
下面是我的HTML中的PHP代码:
<div class="container-fluid" style="margin-top:2em;">
<div class="row">
<div class="col-lg-12" style="background: none;">
<h4>Test Drives</h4>
<?php include 'campaign_detail.inc.php'; ?>
<table class="table table-fixed table-sm table-hover" style="height: 100px; background:pink;">
<thead>
<tr>
<th>
Value
</th>
<th>
Date Submitted
</th>
<th>
User submitted
</th>
<th>
Market
</th>
<th>
Notes
</th>
<th>
Last Update by
</th>
</tr>
</thead>
<tbody>
<?php foreach($testdrives as $tdrrow) {?>
<tr>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_VALUE]";?>
</td>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_DATE_CREATED]";?>
</td>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_USER_CREATED]";?>
</td>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_MARKET]";?>
</td>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_NOTES]";?>
</td>
<td>
<?php echo "$tdrrow[CAMPAIGN_DATA_USER_UPDATED]";?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
你能向我们展示产生HTML的示例代码吗? – JustBaron
我在我的代码片段中的html中添加了PHP代码。 – Chris
问题是,你已经在PHP回声之前放了很多空白,然后在关闭之前再次在下一行标记 –