increase index of array on every refresh of page
-
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
-
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
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.