Storing Banner Data in MySQL Tables for a Dynamic Banner System with AJAX
(Page 1 of 4 )
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.
Introduction
Now that you hopefully have a clear idea of the topics covered by this series, let me reintroduce some important concepts surrounding the implementation of this AJAX-driven banner mechanism, which were deployed in the previous article. As you'll possibly recall, over the course of that tutorial I introduced some changes to the original structure of the original banner system, specifically modifying the definition of one of its primary JavaScript functions, called "displayBanner()."
The most evident consequence in doing this modification was providing the application with the capacity to fetch the set of predefined banners directly from a simple XML file. This change enabled us to avoid needing the code and additional PHP file that initially retrieved all of the banner data from a plain text file. Additionally, since the aforementioned JavaScript function used the XML part of AJAX to display the different banners periodically on the browser, its overall structure became slightly more compact and maintainable.
All right, at this point I already mentioned all the pros of this AJAX-driven application, but I purposely didn't stress its main weakness, so I believe now is a good time to do it, right? As you'll probably remember, the sequence in which the different banners were shown was originally controlled by a unique, global JavaScript variable. This approach can not be recommended in terms of good programming habits.
Thus, considering that this issue should be fixed quickly, in this last installment of the series I'm going to adapt the original structure of the banner system to give it the ability to read all the banner-related data from a simple MySQL database table. In this way we will naturally avoid relying on a rather undesirable global JavaScript variable.
Now, let's get rid of the preliminaries and learn together how to modify the original AJAX application to work with a basic MySQL database table. Hopefully, it's going to be an instructive experience!
Next: Listing the entire source files of the previous banner application >>
More JavaScript Articles
More By Alejandro Gervasio