ARTICLE AD BOX
I am writing a simple web-app to display flashcards using PHP, SQL and HTML.
To show the cards currently created I have a page called view_cards.php which loads with a query string comprising the number of the deck selected followed by the number of the card selected, eg. www.view_cards.php/?deck_id=4&cardNumber=0
To move up and down between the cards the user clicks on icons which are actually the submit buttons of two forms, with hidden fields to pass the number of the deck and the number of the next or previous card into the query string.
<!-- Submit button has hidden field to decrease value of cardNumber --> <form action="view_cards.php" method="get"> <input type="hidden" name="deck_id" value="<?php echo $deck_id; ?>"> <input type="hidden" name="cardNumber" value="<?php echo $cardNumber--; ?>"> <input type="submit" value="Previous Card"> </form> <!-- Submit button has hidden field to increase value of cardNumber --> <form action="view_cards.php" method="get"> <input type="hidden" name="deck_id" value="<?php echo $deck_id; ?>"> <input type="hidden" name="cardNumber" value="<?php echo $cardNumber++; ?>"> <input type="submit" value="Next Card"> </form>Perhaps this isn't the cleanest way of doing it, but as a beginner I thought it should at least work.
However, if I click on the submit button for "Previous Card", the value for cardNumber in the resultant URL stays the same rather than being decremented, and if I click on the submit button for "Next Card", rather than being incremented it actually decreases by 1.
Can anyone suggest a cause for this strange behavior?
