PHP and MySQL Web Development - P16

PHP and MySQL Web Development - P16: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 42 Chapter 1 PHP Crash Course if totalqty 0 echo You did not order anything on the previous page br else if tireqty 0 echo tireqty. tires br if oilqty 0 echo oilqty. bottles of oil br if sparkqty 0 echo sparkqty. spark plugs br elseif Statements For many of the decisions we make there are more than two can create a sequence of many options using the elseif elseif statement is a combination of an else and an if statement. By providing a sequence of conditions the program can check each until it finds one that is true. Bob provides a discount for large orders of discount scheme works like this Less than 10 tires purchased no discount 10-49 tires purchased 5 discount 50-99 tires purchased 10 discount 100 or more tires purchased 15 discount We can create code to calculate the discount using conditions and if and elseif need to use the AND operator to combine two conditions into one. if tireqty 10 discount 0 elseif tireqty 10 tireqty 49 discount 5 elseif tireqty 50 tireqty 99 discount 10 elseif tireqty 100 discount 15 Note that you are free to type elseif or else if with or without a space are both correct. If you are going to write a cascading set of elseif statements you should be aware that only one of the blocks or statements will be executed. It did not matter in this example because all the conditions were mutually exclusive only one can be true at a Making Decisions with Conditionals 43 time. If we wrote our conditions in a way that more than one could be true at the same time only the block or statement following the first true condition would be executed. switch Statements The switch statement works in a similar way to the if statement but allows the condition to take more than two values. In an if statement the condition can be either true or false. In a switch statement the condition can take any number of different values as long as it evaluates to a simple type integer string or double .You need to provide a

Không thể tạo bản xem trước, hãy bấm tải xuống
33    28    1    21-03-2023
458    9    1    21-03-2023
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.