mardi 28 août 2018

Don't display the specific empty column of row from database

I have a working code that can insert and update information from the database and echoing it to page. but I like to hide the specific empty column while displaying all the information from the row. check this screenshot my goal is to hide the "image" column when its null/empty; so the crock image wont display. here is my code below:

 <?php
    $result = mysqli_query($mysqli, "SELECT * FROM blogs ORDER BY id DESC");
    while ($row = mysqli_fetch_array($result)) 

    if (!empty($row['image'] != "")) 

    {
      echo "<div class='row'>
        <div class='col-lg-12 box'>
           <div class='content-heading'>
             <p>
                <text>".$row['title']."</text>
             </p>
           </div>

             <p>    
                <text1 class='pull-right' >".$row['image_text']."</text1><br/>
             <img class='img-size' id='hp'src='admin/upload_images/".$row['image']."'/>

             <text>".$row['definition']."</text> 
            </p>
          </div>
       </div>";     

   }
?>

but this code if (!empty($row['image'] != "")) is hiding all the row from my database. can anyone have the right code from my problem?

Aucun commentaire:

Enregistrer un commentaire