tailieunhanh - PHP 5/MySQL Programming- P75
PHP 5/MySQL Programming- P75: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 | 348 PHP 5 MySQL Programming for the Absolute Beginner 3. Repeats the query creation process building a query that requests only the row associated with the new ID. 4. Pulls the room name from that array. Once that s done it s easy to build the radio button text. The radio button is called room so the next time this program is called the room variable corresponds to the user-selected radio button. Finishing the HTML All that s left is adding a Submit button to the form and closing the form and HTML. The amazing thing is that s all you need. This code alone is enough to let the user play this game. It takes some effort to set up the data structure but then all you do is provide a link to the first record by calling without any parameters . The program will keep calling itself. Viewing and Selecting Records I suppose you could stop there because the game is working but the really great thing about this structure is how flexible it is. It doesn t take much more work to create an editor that lets you add and modify records. This actually requires a couple of PHP programs. The first shown in Figure prints out a summary of the entire game and allows the user to edit any node. figure The program lists all the data and allows the user to choose a record for editing. The code for the program is actually quite similar to the program you saw before. It s simply cleaned up a bit to put the data in tables and has a form to call an editor when the user selects a record to modify. html head title List Segments title style type text css body color red td th color white background-color blue style head body conn mysql_connect localhost select mysql_select_db chapter7 conn sql SELECT FROM adventure result mysql_query sql print HERE form action method post HERE while row mysql_fetch_assoc result print table border 1 width 80 n foreach row as key value print key value br n roomNum row id print
đang nạp các trang xem trước