douerlin4366 2012-10-19 15:20
浏览 31
已采纳

使用PHP从mySQL表显示图像/描述

my php link to database: http://i163.photobucket.com/albums/t315/smc22_2007/pic1.png

My guess at how to show images from mysql database: http://i163.photobucket.com/albums/t315/smc22_2007/pic2.png

what I want it to look like: hxxp://i163.photobucket.com/albums/t315/smc22_2007/pic3.png (unable to post 3 hyperlinks, pls change xx to tt)

Please view the three pictures above in that order.

I can connect & display my database by using an 'include displayitems.php', however, I want to display the images from my database in row of 4 rows of 3 columns.

How do I do this?

I'm getting really confused.

Thankyou

  • 写回答

2条回答 默认 最新

  • douling6469 2012-10-19 15:41
    关注
    <div id='overall'>
    <?php
    $query = "select * from UFPProducts";
    $result = mysql_query ($query, $connect);
    
    while($row = mysql_fetch_array($result)) {
    
    ?>
    
        <div class='container'>
            <div class="image">
                <?php echo "<img src='".$row['Image']."' />"; ?>
            </div>
            <div class="text">
                <?php echo "<p>".$row['Description']."</p>"; ?>
            </div>
        </div>
    
        <?php
    
     }
    
     ?>
     </div>
    
     <style type="text/css">
    
     #overall {width:480px;}
     .container {width:100px; height:150px; float:left; display:inline; margin: 0px 10px; }
     .image {width:100px; height:100px;}
     .text {width:100px; height:50px;}
    
     </style>
    

    The "margin: 0 10px;" is basically saying have no margins on the top or bottom, but have 10px on each side of the container. This means that the container div will be 100px wide still, with 10px of margin (spacing) on each side, therefore making it 100px + 20px wide.

    So if you still want 4 in each row; 120px x 4 = 480px. Thus, 480px is the size of the 'overall' container.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加