Web site counters - Try It Out Calculating Movie Takings In this
Try It Out Calculating Movie Takings In this exercise, you ll create a new page to display the data you added in the previous exercise. 1. Open your text editor and type the following program: 0) { $font_color = green ; $profit_or_loss = $ . $difference . m ; } else { $font_color = blue ; $profit_or_loss = Broke even ; } return . $profit_or_loss . ; } ?> This function will make life easier for you. This will become clearer as we proceed through the rest of this example. 2. Save this file as movie_details.php. How It Works The line that contains the code substr is placed before the $profit_or_loss line because a loss will return a negative number, and no one actually says, The movie made a loss of minus 10 million dollars. Instead we say, The movie lost 10 million dollars. However, what happens when the movie takings are the same as the movie production costs? That s where the last else comes into play. You ve covered all eventualities. The important thing to remember is that in PHP you can very easily create new variables by performing actions on existing ones. Just because you don t hold the information in the database doesn t mean you can t create it. Try It Out Displaying the New Information In this exercise you are going to alter the original master table to include the new data, and this will serve as your new child table. 1. Add the following code to movie_details.php: 124 Chapter 4
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services