Jump to content

Looping webimages


zace66

Recommended Posts

I have a website of grids of webcam images.

I have decided to make a looping webpage where I want just 1 image per page and every 2 seconds moves on to the next image.

 

I have the following code - but it only gets 1 image.  I was going to update the database record  with the next image but have decided it will be easier to get an array and loop round that somehow.  Normally when I loop its easy to display the results in a table but this time i want it to display 1 image (record) at a time then move on...

 

The code below works fine (only showing the first image form the website in my database)

 

I hope someone can help me out please.

TIA

<html>
<head>
<title>My webcam page </title>
</head>


<?php


    $host = 'localhost';    
    $user = 'my_User';
    $pass = 'my_Password';
    $db = 'my_db';


    $con = mysqli_connect($host, $user, $pass, $db) or die(mysqli_connect_error());


    $sql = "SELECT * FROM `websites` WHERE `currentshowing`=1 LIMIT 0, 30 ";
    $result  = mysqli_query($con,$sql);
    if (!$result) 
    {
        die("Error: Data not found..");
    }
    $test = mysqli_fetch_array($result);
    $webpic=$test['webpic'];
    $basesite=$test['basesite'];
    $location=$test['location'];
    
?>


<div align="center">
<h1>MY WEBSITE (Ongoing work)</h1>
</div>


<td><div align="center"><?PHP echo $location; ?><br>
        <a href="<?PHP echo $basesite; ?>">
        <img src="<?PHP echo $webpic; ?>" 
        alt="<?PHP echo $location; ?>" 
        width="80%" border="0"/>
        </a></div></td>


</body>
</html>
 
Link to comment
https://forums.phpfreaks.com/topic/292816-looping-webimages/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.