Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

functions and looping

In HTML table I have 7 different tours (sightseeing tours).
The table has 5 columns:

TOUR CODE: (examples below)
<input type="hidden" value="AEPN4" name="TourCode1">
<input type="hidden" value="AEPSP4" name="TourCode2">

TOUR NAME: (examples below)
<input type="hidden" value="Walking Guided Tour" name="TourName1">
<input type="hidden" value="Day Tour" name="TourName2">

PRICE: (examples below)
<input type="hidden" name="PriceWGT" value="15" onChange="calculate()">
<input type="hidden" name="PriceDT" value="54" onChange="calculate1()">

* The WGT for example is the initial tour name and the JavaScript doing the calculation of the Price and the number of tickets the user selects.

QUANTITY: (examples below)
 <select name="QuantityWGT" onChange="calculate()">
<select name="QuantityDT" onChange="calculate1()">

TOTAL: (examples below)
<input type="text" size="8" name="TotalWGT">
<input type="text" size="8" name="TotalDT">

In the PHP page, the page that gets the variables I used thefunction, “if ($TotalWGT >0)” that’s in order to know which tour/s the user selected. Since I do not know so good how to build functions I actually did it for all the 7 tours. When the function is “true” it echo the all the information from the HTML table for the user last review. (e.g. Tour Code, Tour Name and so on).

THE PROBLEM:

In the review information page (the PHP page) after the user review its selections he has to click on a button that connects to third party credit card billing via CGI script.  

One of their requirements is to send in ONE SUBMITTED variable the information as follow: Tour Code, Number of tickets, and Total for each tour the user has selected.
So basically it can contain all of the 7 tours.

The total sum of all the tours I already managed to do. But I do not know how to “loop” to check which tours are selected and how to combine all this information into one submitted variable.

Please if someone can help me!!!!!
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Use a delimiter to store all the data (i.e. $variable = "var1|var2|var3|etc";) and then send it, they will have to parse it to retrieve all the values, but hey, they want it in one variable right? :)
You could also use an associative array to store the values.

To retrieve the seperate values, use the $_REQUEST variable to loop through the form.

if you need more pointers, let me know...
Avatar of Refael

ASKER

Hi, it will be great if you can show me how it works, pls... i have no idea how to populate this as you suggested.
ASKER CERTIFIED SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial