Welcome Guest, Not a member yet? Register   Sign In
If and elseif Question
#1

[eluser]Jesse Schutt[/eluser]
Hello All,

I am building a simple registration program that is for a Father/Son retreat. The registration cost is 25 dollars per person. The form is to be filled out by the father. Under his information are four fields for additional "guests" or sons. What I am trying to do is calculate the amount of money that should be transferred to PayPal for the total bill.

Could you look at this and let me know if this is the best way to do it?


Code:
if($this->input->post('guest_name_4') != '')
{
      $event_cost = 125;
}
elseif($this->input->post('guest_name_3') != '')
{
      $event_cost = 100;
}
elseif($this->input->post('guest_name_2') != '')
{
      $event_cost = 75;
}
elseif($this->input->post('guest_name_1') != '')
{
      $event_cost = 50;
}


This does work, but I am sure there is a better way to do it...

Thanks in advance!

Jesse


Messages In This Thread
If and elseif Question - by El Forum - 09-06-2008, 03:34 PM
If and elseif Question - by El Forum - 09-06-2008, 03:57 PM
If and elseif Question - by El Forum - 09-06-2008, 04:00 PM
If and elseif Question - by El Forum - 09-06-2008, 04:06 PM
If and elseif Question - by El Forum - 09-06-2008, 05:36 PM
If and elseif Question - by El Forum - 09-06-2008, 06:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB