php - Don't show blank spaces -


i use sql query php code display fields of database on website. there way delete blank spaces (whitespaces) in output of empty (null) fields?

here code:

<?php      $sql = "select * dining order 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>&nbsp;$dining->title</h3> <h4>&nbsp;$dining->comforts</h4>  &nbsp;$dining->com1<br/> &nbsp;$dining->com2<br/> &nbsp;$dining->com3<br/> &nbsp;$dining->com4<br/> &nbsp;$dining->com5<br/> &nbsp;$dining->com6<br/> <h4>&nbsp;$dining->breakers</h4> &nbsp;$dining->break1<br/> &nbsp;$dining->break2<br/> <h4>&nbsp;$dining->wild</h4> &nbsp;$dining->wild1<br/> &nbsp;$dining->wild2<br/> <h4>&nbsp;$dining->tureens</h4> &nbsp;$dining->tur1<br/> &nbsp;$dining->tur2<br/> &nbsp;$dining->tur3<br/> <h4>&nbsp;$dining->desserts</h4> &nbsp;$dining->des1<br/> &nbsp;$dining->des2<br/> &nbsp;$dining->des3<br/> &nbsp;$dining->des4<br/><br/> ";   } ?> 

if want suppress blank values, you'll have test each value individually decide if should output or not, e.g.

if (strlen($dining->des1) > 0) {    echo "&nbsp;{$dining->des1}<br />"; } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -