I have a javascript slideshow that pre-loads images out of a mySQL database and then displays them one at a time in an image tag in the HTML document. Briefly, it accomplishes this by pre-loading images like many slideshow tutorials show on the web, but instead of using static images (i.e. images/image1.jpg etc.) it uses a dynamic image provided via PHP (i.e. getData.php?n=1) The getData.php script runs on the server and opens a new connection to the database for every image that is preloaded.
Is there anyway to avoid making so many connections to the database and having each connection make only a single query on the image database with LIMIT n,1?
It seems that if i am going to use getData.php as the image.src then getData.php needs to return a single image at a time! I'd really like to fetch them in blocks of 10 and then assign them to Image() objects one by one on the client side. I think this would be faster because when I wrote a client app in python to display the images (outside the browser of course) blocks of 10 or so transferred much faster (and reduces the load on the mySQL server). Can I accomplish this with javascript and PHP? Do I use XML in between? If I could get binary image data into javascript with AJAX could I do anything with it? Is there an imagecreatefromstring() function in javascript that I'm missing?
I can figure out exact code on my own, but I'm new to web programming and need a tip about how to tackle this problem! I think I'm missing some piece of major framework. Do I need Actionscript or something other than javascript for this problem? Thanks for the tip in advance!
EDIT: I like this first suggestion and I think I could get that done. It will also enable me too follow part of alex shishkin's suggestion to avoid LIMIT n,1 queries (i do want to keep the sql BLOB fields though) But how do I stick binary data from XML into an Image() object in javascript?