Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:07:07+00:00 2026-05-28T02:07:07+00:00

What I am hoping to do is display the first 5 items (Stage1 –

  • 0

What I am hoping to do is display the first 5 items (Stage1 – Stage5) from the array when the page is loaded. To the side I will have two images one arrow pointing up and one arrow down. If the down arrow is clicked the array is incremented to display (Stage2 – Stage6). Another click on the down arrow the screen would display (Stage3 – Stage7). Then the up arrow does the same but the opposite direction.

With the code I have below I can manually add “1” to $var1 and $var2 or subtract 1 when needed, save and refresh the browser to get the effect I am looking for. I just can’t seem to figure out how to do the increments of $var1 and $var2 and then refresh the page, all automatically when the arrow images are clicked.

I am new so I could be completely off with what I have but hopefully it at least helps show what I want to do.

<?php

$stage_name=array
("Stage1","Stage2","Stage3","Stage4",
"Stage5","Stage6","Stage7","Stage8",
"Stage9","Stage10","Stage11","Stage12",
"Stage13","Stage14","Stage15","Stage16");

?>
<html>
<body>
<?php
$var1=0; $var2=5;
for($list=$var1; $list<$var2; $list++)
{
    foreach($stage_name as $stage_index => $stage_item)
    {
        if ($stage_index==$list)
            print("$stage_item<br />");
    }
}
?>
</body>
</html>

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:07:07+00:00Added an answer on May 28, 2026 at 2:07 am
    $stageNames = array("Stage1", "Stage2", "Stage3", "Stage4",
                        "Stage5", "Stage6", "Stage7", "Stage8",
                        "Stage9", "Stage10", "Stage11", "Stage12",
                        "Stage13", "Stage14", "Stage15", "Stage16");
    
    $offset  = isset($_GET['offset']) ? $_GET['offset'] : 0;
    $perPage = 5;
    
    if ($offset > 0) {
        printf('<a href="here.php?offset=%d">Up</a>', $offset - 1);
    }
    
    foreach (array_slice($stageNames, $offset, $perPage) as $stageName) {
        echo $stageName . '<br>';
    }
    
    if ($offset + $perPage < count($stageNames)) {
        printf('<a href="here.php?offset=%d">Down</a>', $offset + 1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if anybody knew how to display only a few items from
I have a for loop that displays the first six items in a MySQL
Hoping Paul McGuire may spot this and rescue me... I have grabbed the 'regex
I need a bit of inspiration from somewhere and hoping someone, anyone could help.
this will be difficult without pasting my whole code, but I am hoping I'm
Hey im working on my first php site, and was hoping to get some
I’m a long time listener, but first time caller here… Hoping you can help
I want to display a route from my location to a destination. I took
Here's my dilemma. I have 2 animations that need to run sequentially. The first
first post here, hoping someone could perhaps shed some light on an issue I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.