deansaddigh Posted March 26, 2010 Share Posted March 26, 2010 I have this bit of code,which basically looks to see if the course matches what we are looking for then define itsmin and max weeks. [code //deans changes /**************************************************/ if($coursetitle == 'IELTS Exam Preparation') { $maximum = 48; for($week=4; $week<= $maximum; $week+=4) { echo '<option>'.$week.'</option>'; } } /*************************************************/ Simpl right, well if u go here http://www.cisukschool.co.uk/booknow.php?CourseTitle=IELTS Exam Preparation it goes from o4 to 48 in increents of 4 then iafter 48 it goes to2 and ten 48 again, any ideas? Quote Link to comment Share on other sites More sharing options...
ignace Posted March 26, 2010 Share Posted March 26, 2010 Are you referring to "Duration of Accommodation" that goes from 2 to 48? And what code do you use for this? Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted March 26, 2010 Author Share Posted March 26, 2010 Dear god i am so sorry for the last posts rediculous spelling mistakes, for some reason the box was jumping up and down as i was writing, and hence couldnt' see, my appolagise Hi, i think i know whats going on. what im basically trying to do is if a certain course is selected it will show on the form under duration in weeks, what ever i set it, however the if statments are re-writing over each other, if the senario isnt met. heres the whole code //Trim the course titles. $coursetitle = trim($coursetitle); if ($coursetitle == 'Business English') { $maximum = 2; } else { $maximum = 48; } //deans changes /**************************************************/ if($coursetitle == 'IELTS Exam Preparation') { $maximum = 48; for($week=4; $week<= $maximum; $week+=4) { echo '<option>'.$week.'</option>'; } } else { for($week=2; $week<= $maximum; $week+=1) { echo '<option>'.$week.'</option>'; } } /***********************************************/ if($coursetitle == 'IELTS Foundation Test course') { $maximum = 48; for($week=4; $week<= $maximum; $week+=4) { echo '<option>'.$week.'</option>'; } } else { for($week=2; $week<= $maximum; $week+=1) { echo '<option>'.$week.'</option>'; } } as you can see the else statments are messing each other up. Can you show me how i can do it pretty please ? Quote Link to comment Share on other sites More sharing options...
ignace Posted March 26, 2010 Share Posted March 26, 2010 Well sure but I'm gonna need some more info because your code does not make a lot of sense like what are the "else" for? When I rewrite it I get: $course_title = trim($course_title); $course_maxweeks = 48; if ('Business English' === $course_title) { $course_maxweeks = 2;//?? } else if ('IELTS Exam Preparation' === $course_title) { for ($week = 4; $week <= $course_maxweeks; $week += 4) { echo '<option>', $week, '</option>'; } } else if ('IELTS Foundation Test Course' === $course_title) { for ($week = 4; $week <= $course_maxweeks; $week += 4) { echo '<option>', $week, '</option>'; } } else { for ($week = 2; $week <= $course_maxweeks; ++$week) { echo '<option>', $week, '</option>'; } } Notice the question marks on top Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.