I’m hitting a brick wall with this one-
Here’s the codethat I have – it’s meant to have a forward and backward button which allows me to step through an array. But for some weird reason it’s stuck between just two numbers and refuse to show next index in the array.
//$someArray is an array of ten items.
$_SESSION['theResult'] = $someArray;
$prev = $_SESSION['theResult'] [0]--;
$next = $_SESSION['theResult'] [1]++;
echo "<div id='button_div'>
<form action='" . $_SERVER['PHP_SELF'] . "'> <input type='hidden' value='" . $prev. "' name=\"id\" /> <input style='float:left;' class='strong_bttn' type='submit' value='<< Previous'></form>
<form action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' value='" . $next. "' name='id' /><input style='float:right;' class='strong_bttn' type='submit' value='Next >>'></form></div>";
What I want is that when I press next, the button moves to the next index in the array and if prev is pressed, it moves backward.But its just stuck on 1 and 0.
I don’t know if this code makes any sense to anyone. I’m just frustrated and tired that I just want to give up 🙁
Are you trying to iterate through the results array? If yes maybe this can help: