Storing Banner Data in MySQL Tables for a Dynamic Banner System with AJAX
If you're a web developer searching for a guide on how to build a dynamic banner application with AJAX, look no further. This series of articles might be what you need. Welcome to the final tutorial of the series that began with "Creating a Dynamic Banner System with AJAX." Made up of three articles, this series develops a basic web application that uses AJAX-based HTTP requests to display a group of dynamic banners based on a predefined time sequence.
Storing Banner Data in MySQL Tables for a Dynamic Banner System with AJAX - Listing the entire source files of the previous banner application (Page 2 of 4 )
As usual with many of my articles on web development, before I proceed to show you how to modify the original banner system, I'd like to list all of the source files that comprised it originally. Doing so should aid you in comparing this version of the banner application with the one I plan to show you in the next few lines.
That being said, here are the respective signatures for the two source files that makes up this banner system, so have a look at them, please:
(definition of 'dynamic_banner.htm' file)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
As you can see, the above files are all the source code required to get this banner system working seamlessly. The "dynamic_banner_htm" file is responsible first for fetching the banners from the corresponding "banners.xml" XML file via AJAX. Next, it stores the banners into a JavaScript array, and finally it displays them on the browser based upon a predefined time interval (the sample file will show a different banner each 15 seconds, but as you know, this feature is completely customizable).
So far, so good right? Now that you have recalled the definition of the previous source files, it's time to move forward and see how the intrinsic structure of this AJAX-driven application can be slightly modified to fetch all of the banner data straight from a MySQL database table.
Of course, this doesn't imply that you'll have to spend your valuable time defining the database table only for storing a few basic banner images and texts. But following a database-driven approach can lead you to build a full-blown advertising system, which eventually will have many more features than the ones covered here.
Thus, keeping this idea in mind, in the next section I'm going to define a simple MySQL database table for storing all the pertinent banner data, and also modify the definition of the "displayBanner()" JavaScript function that you learned before, so the whole application can interact directly with this database server.