I have a form that lists a number of events which is generated from a database table containing the event details.
On the form, each event has a quantity field with names in the series: qty_event1, qty_event2, qty_event3, etc. with the numbers increasing or decreasing based on the number of events in the database table.
The Problem:
On the next screen after submit I must calculate the total fees for all events...
Hard coding the following for each event works, but I need to figure out a way to do this dynamically:
if ($_SESSION[qty_event1]){
$res = mysql_query("SELECT * FROM events where id='$_SESSION[event1_id]'");
$ar = mysql_fetch_array($res);
$event1fee = $_SESSION[qty_event1] * $ar[fee];
}
I thought of using a foreach or while loop, but cannot figure out how to do it since the number that changes is part of the variable name.
Any ideas on a better approach?
Thank you all!