Jump to content

Just need help with an if stament


deansaddigh

Recommended Posts

Hi guys and thanks in advance for any help.

All i want to do is check if the course id is 44 or 72

im getting course id here

 

$courseid=$rowcourseid['CourseId'];

 

i need to perfom the code below changing the courseprice based on if the ids are 44 or 72

 

Now all i want to do is if the course id is 44 and the duration is 2-11 weeks set the price to 110 if its 12 -23 week price equals 95 and if its 24-48course price equas £75

then it can be added to accomodation price to get a total price etc.

 

Also if the course is id 72 then i want to do similar again where 2-11 weeks = 140, 12-23 weeks =120, 24-48 weeks = 110

 

and then finally if the id isnt any of those just perform the code below.


//Do the calculation of the courseprice * the amount of weeks plus the enrolment fee - include accomodation if neccessary
if ($accomodationflag)
{ 
	$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
	$totalprice = $totalpriceaccomodation + $courseprice;	 
}
else
{
	$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
	$totalprice = $courseprice;
}

 

Please can someone help me i have got this far on my own just need a little help with this.

 

Thanks very much in advance

Link to comment
https://forums.phpfreaks.com/topic/196220-just-need-help-with-an-if-stament/
Share on other sites

Hi i have made an attempt an wrapped the previous code in an ifstament. to check if the ids i want are present.

 

does this look correct, if so all i need to do is check if weeks and set prices based on it.

 

	//do calcultions based on general english
if ($courseid =='44')
{	if ($accomodationflag)
	{ 
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $totalpriceaccomodation + $courseprice;	 
	}
	else
	{
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $courseprice;
	}
}

//do calculations based on intensive english course
if ($courseid =='72')
{	if ($accomodationflag)
	{ 
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $totalpriceaccomodation + $courseprice;	 
	}
	else
	{
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $courseprice;
	}
}

else // if the ids are not what i want do the following
{
	if ($accomodationflag)
	{ 
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $totalpriceaccomodation + $courseprice;	 
	}
	else
	{
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $courseprice;
	}

}

Sorry i dont mean to re-post just checking if i have done the if statment correctly.

 

//do calcultions based on general english
//do calcultions based on general english
if ($courseid =='44')
{	if ($accomodationflag)
	{ 	
		if($durationweeks <=11)
			{
			$courseprice = 110
			}
		elseif($durationweeks >=11 && <=23)
			{
			$courseprice = 95
			}
		elseif($durationweeks >=24 	&& <=48)
			{
			$courseprice = 75
			}
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $totalpriceaccomodation + $courseprice;	 
	}
	else
	{
		$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
		$totalprice = $courseprice;
	}
}
else 
{
	$courseprice = ($courseprice * $durationweeks) + $enrolmentfee;
	$totalprice = $courseprice;
}

 

hopefully this should check to course id if its

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.