Chapter 13. Serving from SQL
Over the past few chapters we have learned why a DBMS is superior to a flat file. But so far our working system transmitted XML to the Flash client either from flat files or from hard-coded tables in the script.
In this chapter, we use PHP to access a MySQL database and dynamically generate the question that is then passed on to the Flash client. To do so, we first learn how to connect to the database. Then we use PHP to query the database. The information is returned to us in a table, which our PHP script must translate to XML. Finally, we send this XML to the Flash client. At the end of the chapter, we have this model in place: database to PHP to Flash (Figure 13.1).
Figure 13.1. The Flow of Data in Chapter 13