Order Page: On this page, customers can choose to add business card orders with different foreign languages and other options.
When the user clicks on a button to add an additional card, javaScript adds a series of form fields and in order to give them unique name attributes, I am simply adding a counter variable at the end of the name for each group of fields, so I can save them as a unique group of session variables where each form field has different names but the same counter number at the end so I know they belong together.
These are the session variables I am saving when the user submits the form to go to the next page:
- $_SESSION[quantity1] = 500
- $_SESSION[language1] = Korean
- $_SESSION[quantity2] = 250
- $_SESSION[language2] = Chinese
Checkout Page: On this page, I want it to echo out the information for each different card ordered.
I am trying to echo out all the session variables with the same number at the end of the session variable on the checkout page. So far I'm using a foreach loop to echo out all the session variables, but I am trying to only echo out the ones with a '1' at the end of the names, or a '2' at the end of the names, etc, and group them together.
So ideally, I would like something like this:
Order #1,
Quantity: 500,
Language on Card: KoreanOrder #2,
Quantity: 250,
Language on Card: Chinese
How can I echo and group these dynamic session variables on the checkout page?