PHP 5/MySQL Programming- P29:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 118 PHP 5 MySQL Programming for the Absolute Beginner html head title poker dice title style type text css body background green color tan style head body center h1 Poker Dice h1 form Building the Main Code Body The Poker Dice program is long enough to merit functions. I broke it into smaller segments here but you may want to look at its entirety which is on the CD that accompanies this book. The main part of the code sets up the general program flow. Most of the work is done in other functions called from this main area. check to see if this is first time here if empty cash cash 100 end if rollDice if secondRoll TRUE print h2 Second roll h2 n secondRoll FALSE evaluate else print h2 First roll h2 n secondRoll TRUE end if printStuff The first order of business See if this is the first time the user has come to this page. It s important to understand how timing works in this program. The user thinks he is playing the same game for several turns but the entire program runs again each time he rolls the dice. The program has different behavior based on which form elements if any have values. If the user has never been to the page before the value for the cash variable is null. The first if statement checks this condition. If the cash variable has not yet been created the user gets a starting value of 100. I wish real casinos worked like this. The program then calls the rollDice function which is described momentarily. This function rolls the dice and prints them to the screen. If you look carefully at the program as it is running you see it runs in two different modes. Each turn consists of two possible rolls. On the first roll the user is given the ability to save a roll with a checkbox. No scoring is performed. The second roll has no checkboxes because the user needs to start with all fresh dice on the next turn . The program tracks the player s score by adding money for various combinations. The secondRoll variable keeps track of whether the user is on the second .