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

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

问题描述:

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

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.