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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.