how to hide a td when dynamically getting data in php codeigniter?

i have a form displaying in a table dynamically working properly but my issue is if one field is empty in database in front end i want to hide that field. here is my view code

<?php
         foreach($jobs as $row)
         {
              ?>
               <tr>
               <?php
               if($row->job_advantage_skills = '')
               {?>
               <td valign="middle"><strong>Advantage:</strong><?php echo $row->job_advantage_skills; ?></td>
               <?
               }
               ?>
               </tr>
           <?
            }
            ?>

here i have given if($row->job_advantage_skills = '') {} for this i want to hide if there is advantage skills hide this field in front end.


I think you want to hide the field if ' $row->job_advantage_skills ' is empty:-

So, instead of using (= or == or ===) you have to use != (not equals to)

So, your code will be:-

<?php
           if($row->job_advantage_skills != '')
           {?>
               <td valign="middle"><strong>Advantage:</strong><?php echo $row->job_advantage_skills; ?></td>
           <?
           }
?>

OR

You can also use [ !empty() ]:-

<?php
               if(!empty($row->job_advantage_skills))
               {?>
                   <td valign="middle"><strong>Advantage:</strong><?php echo $row->job_advantage_skills; ?></td>
               <?
               }
    ?>

  • Use == / === not = . Check php comparison operators .
  • To hide the <td> use display:none or add a css class with display:none property.

  • <?php
    if($row->job_advantage_skills == '')
    {?>
    
       <td valign="middle" style="display:none"><strong>Advantage:</strong><?php echo $row->job_advantage_skills; ?></td>
    
    <?
    }
    ?>
    

    you just set the value for $row->job_advantage_skills = "" . if check condition is null put == or ===

    if($row->job_advantage_skills == '')
    
    链接地址: http://www.djcxy.com/p/58602.html

    上一篇: 递归函数和多维数组

    下一篇: 如何在php codeigniter中动态获取数据时隐藏td?