0

我从表中的数据库输出数据。

在使用下一个代码创建的结果表中:

while($i=$res2->fetch_assoc()) {
    $a++;
    $t2.='
    <tr>
    <td>'.$a.'</td>
    <td>'.date_format(new DateTime($i['date']),'d.m.Y').'</td>
    ';

    if($valid!='id'){
        $t2.='
        <td>'.$partner.'</td>
        ';
    }

    $t2.='
    <td>'.$http_referer.'</td>
    </tr>';
}
$t1='
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="column_th_number">№&lt;/th>
<th>Date</th>
';

if($valid!='id'){
    $t1.='
    <th>Partner</th>
    ';
}


$t1.='
<th></th>
</tr>
<tr>
<td colspane="2">
&nbsp;
</td>
</tr>
</thead>
<tbody>
';
$t3='
</tbody>
</table>
';
echo $t1.$t2.$t3;

但在结果中我看到最后一行没有关闭(见图):

测试图像

请告诉我为什么最后一行没有关闭?

我怎样才能做到这一点?

4

3 回答 3

3
<td>'.date_format(new DateTime($i['date']),'d.m.Y').'</td>
if($valid!='id'){

用。。。来代替

<td>'.date_format(new DateTime($i['date']),'d.m.Y').'</td>'; <--- end the string here
if($valid!='id'){
于 2013-02-19T12:25:17.507 回答
2

你错过了';

<td>'.$a.'</td>
<td>'.date_format(new DateTime($i['date']),'d.m.Y').'</td>';
if($valid!='id'){
于 2013-02-19T12:26:08.503 回答
1

谢谢大家。

colspan 出错(值与列数不匹配)。

谢谢大家的帮助

于 2013-02-19T12:51:07.290 回答