Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. increase index of array on every refresh of page

increase index of array on every refresh of page

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
databasecomdata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blue_Boy
    wrote on last edited by
    #1

    I have an array with 5 items and I want to increase index of array everytime when browser get refresh. In case when array is last index then next index whould start from first item. Regards.


    I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

    G 1 Reply Last reply
    0
    • B Blue_Boy

      I have an array with 5 items and I want to increase index of array everytime when browser get refresh. In case when array is last index then next index whould start from first item. Regards.


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      To do this you will need to store the index that you are currently visiting in the session of the user, unless you want to include it in every link which won't cover a refresh (F5 button). Storing it in the session could be done simply by:

      session_start();

      if ( !isset($_SESSION['index']) ) {
      $_SESSION['index'] = 0;
      }

      $_cur_index = $_SESSION['index'];

      //.. do your stuff

      $_SESSION['index'] = ++$_cur_index;

      Note that if a browser uses caching this might not work, as the browser may never issue a request to the server.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups