dpl3350 2012-07-28 10:15
浏览 30
已采纳

从投资组合页面获取图像并在主页上发布

Hi I have created myself a portfolio website.On the homepage in the footer on the right I would like to add four images from the portfolio page that change every time the page is loaded.Can anyone tell me how this can be achived?

On the portfolio page this is the structure for the html:

<ul class="ourHolder">
        <li class="item" data-id="id-1" data-type="websites" >
            <img src="img/portfolio/websites/small/1.jpg" alt="">
            <div class="full"></div>
        </li>
        </li>
            <li class="item" data-id="id-2" data-type="pdesigns">
            <img src="img/portfolio/Print/small/1.jpg" alt="" />
            <div class="full"></div> 
        </li>
        <li class="item" data-id="id-3" data-type="ldesign">
            <img src="img/portfolio/Logo/small/001.jpg" alt="" />
            <div class="full"></div>
        </li>
 ....
 </ul>

I am using the jquery quicksand plugin to create a nice effect.I am trying to randomnly get 4 images from this page and post them on the homepage in the footer.Here is my website:

foxteam.net

  • 写回答

1条回答 默认 最新

  • dongyun7571 2012-07-28 10:23
    关注

    Based on the information you provided, here's what you can do

    //Database connection here
    $sql="
    SELECT image_link FROM photos
    ORDER BY RAND()
    LIMIT 4";
    //Executing the query here
    while($row = $result->fetch()){
      echo '<img src="', $row['image_link'], '" />';
    }
    

    Edit: Please note that ORDER BY RAND() has some performance issues with big tables, if your "gallery" table is under 100, then I don't think you should worry about it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 hexo+github部署博客
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?