k21chrono Posted November 4, 2009 Share Posted November 4, 2009 See topic for the question, thank you ahead of time. Link to comment https://forums.phpfreaks.com/topic/180304-how-would-you-make-a-button-make-the-php-select-the-next-item-in-an-array/ Share on other sites More sharing options...
simshaun Posted November 4, 2009 Share Posted November 4, 2009 This a homework question? <?php $array = array( 'Item 1' ,'Item 2' ,'Item 3' ); $curIndex = isset($_GET['index']) ? (int) $_GET['index'] : 0; $nextIndex = $curIndex + 1 >= count($array) || $curIndex < 0 ? 0 : $curIndex + 1; echo 'Current item: '. $array[$curIndex]; ?> <form method="post" action="?index=<?php echo $nextIndex; ?>"> <input type="submit" name="submit" value="Next Element" /> </form> Link to comment https://forums.phpfreaks.com/topic/180304-how-would-you-make-a-button-make-the-php-select-the-next-item-in-an-array/#findComment-951128 Share on other sites More sharing options...
k21chrono Posted November 5, 2009 Author Share Posted November 5, 2009 It is sort of a school question, i get to work independantly in my web design class and i am trying to make sort of a media selectory with a back and forward button. Link to comment https://forums.phpfreaks.com/topic/180304-how-would-you-make-a-button-make-the-php-select-the-next-item-in-an-array/#findComment-951889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.