Jump to content

Continuous looping through dynamic links


evilbert

Recommended Posts

Can someone please help me?

 

Scenario:  Database table with varying amount of records, these will be displayed on a big screen with no user interaction, updating every set amount of time say 15 seconds.  Once new data enters the database the page updates and shows that record.  As there is only limited space on the screen i can only show e.g 1 record per page.  I setup pagination which splits these records up into separate pages.  so

 

if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };

$start_from = ($page-1) * 1;

$query = "SELECT * FROM table ORDER BY id ASC LIMIT $start_from, 1";

// run the query and store the results in the $result variable.

$result = $mysqli->query($query) or die(mysqli_error($mysqli));

 

then output the links

 

        $total_pages = ceil($total / 1);

for ($i=1; $i<=$total_pages; $i++) {

echo "<a href=bigscreen.php?page=".$i.">".$i."</a> ";

 

}

 

This is all working fine and splits the pages and displays the links. 

 

Problem:

 

I have been trying to get the page bigscreen.php to automatically loop through the pages that are created e.g 3 records = 3 pages so i want it to load bigscreen.php?page=1 then wait for 15 seconds then update to bigscreen.php?page=2 then 15 seconds then update to bigscreen.php?page=3 then back to bigscreen.php?page=1 and this will continue to do this for the amount of pages created.

 

I have tried various methods but i am struggling.  I keep getting a redirect loop error in chrome when i setup my loop.  I was thinking of putting the links into an array? but i dont know that will work!  Any help or tips would be greatly appreciated!

 

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.