Flash: how to display results of data query - SQL vs. XML (or other)?

I am trying to create a flash Banner Advertisement that will use a database to create a ZIP Code locator. This advertisement will likely get a lot of hits so I need a very efficient solution.

The banner ad will let the user input a ZIP Code into a form field which, when submitted, will query a database to find matching data (i.e. store information) and then display the results in the flash banner file.

I *think* I can do this using an XML file (i.e. instead of querying a database, query the XML file) However, with 20,000+ ZIP Codes and related data nodes, this could be a HUGE XML file - and I'm not 100% positive it is possible.

Is it possible to query a database directly? I suspect so but my concern here is that the banner ad will get tons of hits and strain the database.

Has anybody done something like this before?

What is the best solution?!
Who is Participating?
Jakob_EConnect With a Mentor Commented:

20,000 nodes of 5-50 characters each will result in a 150-450 KB XML file (you don't want that ;-)

I would do something like this:

// Function that submits the user input to the data base - that
// after processing returns XML containing just enough info
function submitToDB():void{
    // Loader and listener
    var loader:URLLoader=new URLLoader()
    // Request and request method (GET/POST)
    var request:URLRequest=new URLRequest("http://www.domain.com/getZipInfo.php")
    // Variables and values
    var vars:URLVariables
        vars.zipCodeInput="10007" // Replace with user input
    // Add variables to the request and load

// Function to handle the XML returned
function resutlFromDBHandler(e:Event):void{
    var xml:XML=new XML(e.data)
    // do other stuff here

Jakob E

Second function should be resultFromDBHandler not resutl..

Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:
Agree with above that you can go through PHP.  Here is a reference to support that using Flex.

bearclaws75Author Commented:
Thanks. This is exactly what I was looking for.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.