Don't print blank lines when data fields are empty











up vote
0
down vote

favorite












Using Wordpress woocommerce theme.Result leaves a empty space if form field is left blank.I Don't want to print blank lines when input data fields of a form are empty.So if QC and QO in form are left blank it prints blank space in output form.Check image



      $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
if( ! empty( $feild1 ) )
$res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
$res .= '</li>';
if( ! empty( $feild2 ) )
$res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
$res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
$res .= '</li>';
if( ! empty( $feild3 ) )
$res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
$res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
$res .= '</li>';
if( ! empty( $feild4 ) )
$res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
$res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
$res .= '</li>';

#where feild xxx=get_post_meta($post->ID,'_input_feild xxx', TRUE );


and




is it better to delete meta value from post if left blank as DB can be
full of blank meta data.Should we delete meta_value with empty or null
value.will it effect anything.




Vlank space created










share|improve this question




























    up vote
    0
    down vote

    favorite












    Using Wordpress woocommerce theme.Result leaves a empty space if form field is left blank.I Don't want to print blank lines when input data fields of a form are empty.So if QC and QO in form are left blank it prints blank space in output form.Check image



          $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
    if( ! empty( $feild1 ) )
    $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
    $res .= '</li>';
    if( ! empty( $feild2 ) )
    $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
    $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
    $res .= '</li>';
    if( ! empty( $feild3 ) )
    $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
    $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
    $res .= '</li>';
    if( ! empty( $feild4 ) )
    $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
    $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
    $res .= '</li>';

    #where feild xxx=get_post_meta($post->ID,'_input_feild xxx', TRUE );


    and




    is it better to delete meta value from post if left blank as DB can be
    full of blank meta data.Should we delete meta_value with empty or null
    value.will it effect anything.




    Vlank space created










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Using Wordpress woocommerce theme.Result leaves a empty space if form field is left blank.I Don't want to print blank lines when input data fields of a form are empty.So if QC and QO in form are left blank it prints blank space in output form.Check image



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
      if( ! empty( $feild1 ) )
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild2 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild3 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild4 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
      $res .= '</li>';

      #where feild xxx=get_post_meta($post->ID,'_input_feild xxx', TRUE );


      and




      is it better to delete meta value from post if left blank as DB can be
      full of blank meta data.Should we delete meta_value with empty or null
      value.will it effect anything.




      Vlank space created










      share|improve this question















      Using Wordpress woocommerce theme.Result leaves a empty space if form field is left blank.I Don't want to print blank lines when input data fields of a form are empty.So if QC and QO in form are left blank it prints blank space in output form.Check image



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
      if( ! empty( $feild1 ) )
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild2 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild3 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
      $res .= '</li>';
      if( ! empty( $feild4 ) )
      $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
      $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
      $res .= '</li>';

      #where feild xxx=get_post_meta($post->ID,'_input_feild xxx', TRUE );


      and




      is it better to delete meta value from post if left blank as DB can be
      full of blank meta data.Should we delete meta_value with empty or null
      value.will it effect anything.




      Vlank space created







      css wordpress forms woocommerce






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 6:13

























      asked Nov 22 at 4:42









      Ferna

      176




      176
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Try this code



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( stripslashes($feild1) ) )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild2) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild3) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild4) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';


          Try this css



          .acc-t ul{
          margin-bottom:0px !important;
          margin-top:0px !important;
          }





          share|improve this answer























          • No it doesnt work
            – Ferna
            Nov 22 at 5:55










          • all feilds still have blank output.any other solution
            – Ferna
            Nov 22 at 6:33












          • use var_dump to print $feild2 value ans share me here
            – Vel
            Nov 22 at 7:10












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
            – Ferna
            Nov 22 at 7:34












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
            – Ferna
            Nov 22 at 7:44


















          up vote
          0
          down vote













          You can use this as well. Give it a try if this works...



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( $feild1 ) && strlen($feild1) > 0 )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild2 ) && strlen($feild2) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild3 ) && strlen($feild3) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild4 ) && strlen($feild4) > 0)
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';





          share|improve this answer





















          • no it doesnt work.it shows as blank space
            – Ferna
            Nov 22 at 8:52










          • do an echo inside the if condition where it the black space is coming.... let me know the output
            – OneJeet
            Nov 22 at 9:17










          • { echo "Have a good day!"; }else { echo 'good day"'; } no error
            – Ferna
            Nov 22 at 10:09












          • Not clear. please echo the respective field value inside if for which the field value expected to be empty
            – OneJeet
            Nov 22 at 10:18










          • didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
            – Ferna
            Nov 22 at 10:49













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424010%2fdont-print-blank-lines-when-data-fields-are-empty%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Try this code



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( stripslashes($feild1) ) )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild2) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild3) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild4) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';


          Try this css



          .acc-t ul{
          margin-bottom:0px !important;
          margin-top:0px !important;
          }





          share|improve this answer























          • No it doesnt work
            – Ferna
            Nov 22 at 5:55










          • all feilds still have blank output.any other solution
            – Ferna
            Nov 22 at 6:33












          • use var_dump to print $feild2 value ans share me here
            – Vel
            Nov 22 at 7:10












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
            – Ferna
            Nov 22 at 7:34












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
            – Ferna
            Nov 22 at 7:44















          up vote
          0
          down vote













          Try this code



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( stripslashes($feild1) ) )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild2) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild3) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild4) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';


          Try this css



          .acc-t ul{
          margin-bottom:0px !important;
          margin-top:0px !important;
          }





          share|improve this answer























          • No it doesnt work
            – Ferna
            Nov 22 at 5:55










          • all feilds still have blank output.any other solution
            – Ferna
            Nov 22 at 6:33












          • use var_dump to print $feild2 value ans share me here
            – Vel
            Nov 22 at 7:10












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
            – Ferna
            Nov 22 at 7:34












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
            – Ferna
            Nov 22 at 7:44













          up vote
          0
          down vote










          up vote
          0
          down vote









          Try this code



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( stripslashes($feild1) ) )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild2) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild3) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild4) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';


          Try this css



          .acc-t ul{
          margin-bottom:0px !important;
          margin-top:0px !important;
          }





          share|improve this answer














          Try this code



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( stripslashes($feild1) ) )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild2) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild3) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( stripslashes($feild4) ) )
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';


          Try this css



          .acc-t ul{
          margin-bottom:0px !important;
          margin-top:0px !important;
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 at 8:04

























          answered Nov 22 at 5:36









          Vel

          6,02941843




          6,02941843












          • No it doesnt work
            – Ferna
            Nov 22 at 5:55










          • all feilds still have blank output.any other solution
            – Ferna
            Nov 22 at 6:33












          • use var_dump to print $feild2 value ans share me here
            – Vel
            Nov 22 at 7:10












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
            – Ferna
            Nov 22 at 7:34












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
            – Ferna
            Nov 22 at 7:44


















          • No it doesnt work
            – Ferna
            Nov 22 at 5:55










          • all feilds still have blank output.any other solution
            – Ferna
            Nov 22 at 6:33












          • use var_dump to print $feild2 value ans share me here
            – Vel
            Nov 22 at 7:10












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
            – Ferna
            Nov 22 at 7:34












          • C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
            – Ferna
            Nov 22 at 7:44
















          No it doesnt work
          – Ferna
          Nov 22 at 5:55




          No it doesnt work
          – Ferna
          Nov 22 at 5:55












          all feilds still have blank output.any other solution
          – Ferna
          Nov 22 at 6:33






          all feilds still have blank output.any other solution
          – Ferna
          Nov 22 at 6:33














          use var_dump to print $feild2 value ans share me here
          – Vel
          Nov 22 at 7:10






          use var_dump to print $feild2 value ans share me here
          – Vel
          Nov 22 at 7:10














          C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
          – Ferna
          Nov 22 at 7:34






          C:wampwwwwordpresswp-contentpluginscustomcustom.php:1127:string '' (length=0) ......its a code which i uploaded in form of plugin by name custom
          – Ferna
          Nov 22 at 7:34














          C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
          – Ferna
          Nov 22 at 7:44




          C:wampwwwwordpresswp-contentpluginscustomcustom.php:1123:string 'test' (length=4) this is for $feild1
          – Ferna
          Nov 22 at 7:44












          up vote
          0
          down vote













          You can use this as well. Give it a try if this works...



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( $feild1 ) && strlen($feild1) > 0 )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild2 ) && strlen($feild2) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild3 ) && strlen($feild3) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild4 ) && strlen($feild4) > 0)
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';





          share|improve this answer





















          • no it doesnt work.it shows as blank space
            – Ferna
            Nov 22 at 8:52










          • do an echo inside the if condition where it the black space is coming.... let me know the output
            – OneJeet
            Nov 22 at 9:17










          • { echo "Have a good day!"; }else { echo 'good day"'; } no error
            – Ferna
            Nov 22 at 10:09












          • Not clear. please echo the respective field value inside if for which the field value expected to be empty
            – OneJeet
            Nov 22 at 10:18










          • didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
            – Ferna
            Nov 22 at 10:49

















          up vote
          0
          down vote













          You can use this as well. Give it a try if this works...



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( $feild1 ) && strlen($feild1) > 0 )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild2 ) && strlen($feild2) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild3 ) && strlen($feild3) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild4 ) && strlen($feild4) > 0)
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';





          share|improve this answer





















          • no it doesnt work.it shows as blank space
            – Ferna
            Nov 22 at 8:52










          • do an echo inside the if condition where it the black space is coming.... let me know the output
            – OneJeet
            Nov 22 at 9:17










          • { echo "Have a good day!"; }else { echo 'good day"'; } no error
            – Ferna
            Nov 22 at 10:09












          • Not clear. please echo the respective field value inside if for which the field value expected to be empty
            – OneJeet
            Nov 22 at 10:18










          • didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
            – Ferna
            Nov 22 at 10:49















          up vote
          0
          down vote










          up vote
          0
          down vote









          You can use this as well. Give it a try if this works...



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( $feild1 ) && strlen($feild1) > 0 )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild2 ) && strlen($feild2) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild3 ) && strlen($feild3) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild4 ) && strlen($feild4) > 0)
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';





          share|improve this answer












          You can use this as well. Give it a try if this works...



            $res .= '<li class="acc-t"><span id="si"><u>QA:</u></span>';
          if( ! empty( $feild1 ) && strlen($feild1) > 0 )
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild1.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild2 ) && strlen($feild2) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QC:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild2.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild3 ) && strlen($feild3) > 0 )
          $res .= '<li class="acc-t"><span id="si"><u>QO:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild3.'</div></span>';
          $res .= '</li>';
          if( ! empty( $feild4 ) && strlen($feild4) > 0)
          $res .= '<li class="acc-t"><span id="si"><u>QP:</u></span>';
          $res .= '<span id="hh" ><div class="acc-cont">'.$feild4.'</div></span>';
          $res .= '</li>';






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 at 8:11









          OneJeet

          898210




          898210












          • no it doesnt work.it shows as blank space
            – Ferna
            Nov 22 at 8:52










          • do an echo inside the if condition where it the black space is coming.... let me know the output
            – OneJeet
            Nov 22 at 9:17










          • { echo "Have a good day!"; }else { echo 'good day"'; } no error
            – Ferna
            Nov 22 at 10:09












          • Not clear. please echo the respective field value inside if for which the field value expected to be empty
            – OneJeet
            Nov 22 at 10:18










          • didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
            – Ferna
            Nov 22 at 10:49




















          • no it doesnt work.it shows as blank space
            – Ferna
            Nov 22 at 8:52










          • do an echo inside the if condition where it the black space is coming.... let me know the output
            – OneJeet
            Nov 22 at 9:17










          • { echo "Have a good day!"; }else { echo 'good day"'; } no error
            – Ferna
            Nov 22 at 10:09












          • Not clear. please echo the respective field value inside if for which the field value expected to be empty
            – OneJeet
            Nov 22 at 10:18










          • didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
            – Ferna
            Nov 22 at 10:49


















          no it doesnt work.it shows as blank space
          – Ferna
          Nov 22 at 8:52




          no it doesnt work.it shows as blank space
          – Ferna
          Nov 22 at 8:52












          do an echo inside the if condition where it the black space is coming.... let me know the output
          – OneJeet
          Nov 22 at 9:17




          do an echo inside the if condition where it the black space is coming.... let me know the output
          – OneJeet
          Nov 22 at 9:17












          { echo "Have a good day!"; }else { echo 'good day"'; } no error
          – Ferna
          Nov 22 at 10:09






          { echo "Have a good day!"; }else { echo 'good day"'; } no error
          – Ferna
          Nov 22 at 10:09














          Not clear. please echo the respective field value inside if for which the field value expected to be empty
          – OneJeet
          Nov 22 at 10:18




          Not clear. please echo the respective field value inside if for which the field value expected to be empty
          – OneJeet
          Nov 22 at 10:18












          didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
          – Ferna
          Nov 22 at 10:49






          didn't get you ,it is still showing blank.so....if ! empty then results are displayed and if empty results are not displayed which i am expecting but it displays blank space of field 2 n 3
          – Ferna
          Nov 22 at 10:49




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424010%2fdont-print-blank-lines-when-data-fields-are-empty%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks