简体   繁体   English

使用PHP和HTML显示存储在数据库中的图像

[英]Displaying images stored in a database using PHP & HTML

I want to display the Images I've stored in my database in this HTML table. 我想在此HTML表中显示存储在数据库中的图像。 I've stored the files as 'BLOB' and I'd like the Images to be displayed under the 'Photo' column. 我已将文件存储为“ BLOB”,并且希望将图像显示在“照片”列下。 What code do I use to echo out the images? 我用什么代码回显图像?

    <table wactidth='100%' border='1' cellspacing='0' align="center">
    <thead align='left'>
        <th>Photo</th>
        <th>Act Name</th>   
        <th>Genre</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Number of People</th>
        <th>Actions</th>

    </thead>
    <tbody>
    <?php foreach($acts as $act):?>
        <tr>
            <td><!-- I WANT TO DISPLAY THE IMAGES UNDER THIS COLUMN--></td>
            <td><?php echo $act['ActName'];?></td>
            <td><?php echo $act['Genre'];?></td>
            <td><?php echo $act['ContactFirstName'];?></td>
            <td><?php echo $act['ContactLastName'];?></td>
            <td><?php echo $act['NumberOfPeople'];?></td>
            <td><a href="?editact&actid=<?php echo $act['actid'];?>">Edit</a>|<a href="?delete&actid=<?php echo $act['actid'];?>">Delete</a>|<a href="upload&actid=<?php echo $act['actid'];?>">Upload Image</td>
        </tr>
    <?php endforeach?>
    </tbody>
</table>

I would recommend storing just the paths to the images, like "/path/to/your/image.jpg". 我建议只存储图像的路径,例如“ /path/to/your/image.jpg”。 Then you can echo out the path just like a string 然后,您可以像字符串一样回显路径

<td><img src="<?php echo $act['imagepath'];?>" alt="" /></td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM