我使用 PHP 代码中的 SQL 查询在网站上显示数据库的字段。有没有办法删除空(NULL)字段输出中的空格(whitespaces)?
这是我的代码:
<?php
$sql = "SELECT * FROM dining ORDER BY date DESC LIMIT 0, 3";
$dining = new Database($sql);
while($dining->results()){
echo "
<span class='date'>". date("F jS, Y", strtotime($dining->date)) ."</span>
<h3> $dining->title</h3>
<h4> $dining->Comforts</h4>
$dining->com1<br/>
$dining->com2<br/>
$dining->com3<br/>
$dining->com4<br/>
$dining->com5<br/>
$dining->com6<br/>
<h4> $dining->Breakers</h4>
$dining->break1<br/>
$dining->break2<br/>
<h4> $dining->Wild</h4>
$dining->wild1<br/>
$dining->wild2<br/>
<h4> $dining->Tureens</h4>
$dining->tur1<br/>
$dining->tur2<br/>
$dining->tur3<br/>
<h4> $dining->Desserts</h4>
$dining->des1<br/>
$dining->des2<br/>
$dining->des3<br/>
$dining->des4<br/><br/>
";
}
?>