Home > database >  How to show image in table using PHP
How to show image in table using PHP

Time:05-09

I tried the following code to show my SQL database data in a table in my dashboard

<tbody>
   <?php
   while ($row = $result->fetch_assoc()):?>
   <tr>
     <td><?php echo $row['id']; ?></td>
     <td><img src="<?php echo $row['image']; ?>" width=100px height=100px></td>;
     <td><?php echo $row['class']; ?></td>
     <td><?php echo $row['reg_no']; ?></td>
     <td><?php echo $row['capacity']; ?></td>
     <td><?php echo $row['oname']; ?></td>
     <td><?php echo $row['province']; ?></td>
     <td><?php echo $row['district']; ?></td>
     <td><?php echo $row['contact']; ?></td>
     <td><a href="#" >
        <i ></i></a></td>
     <td><a href="#" >
       <i ></i></a></td>
     <td><a href="#" >
          <i ></i></a></td>
 </tr>
 <?php endwhile; ?>
</tbody>

But that image column image does not show has an image Result show like this:

my result

How to solve that problem

CodePudding user response:

To me it seems your are inserting to the src attribute the context of the file rather then the URL of the image.

CodePudding user response:

you are saving the image content it self in the DB, check this out :

https://www.codexworld.com/upload-store-image-file-in-database-using-php-mysql/

  • Related