Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 172085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:06:11+00:00 2026-05-11T13:06:11+00:00

I have a JavaScript slideshow that pre-loads images out of a MySQL database and

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:06:11+00:00Added an answer on May 11, 2026 at 1:06 pm

    I would say:

    • Have the getData.php generate an XML file that contains the next 10 images.
    • Have javascript to get the XML response from an AJAX-Request to getData.php.
    • Traverse the images in the XML response one by one and when the ninth images is displayed query the getData.php for the next set of images.

    As for a framework: My advice is to use JQuery for both the AJAX request and the image display and preloading.


    You can use a binary-to-text encoding like base64 to pass the binary data through XML. In most browsers you can use the base64 decode by itself and pass it to an image object like so:

    <img src='data:image/jpeg;base64,your binary data comes here'> 

    This will work in all but Internet Explorer, you can use a neat trick by Dean Edwards to pass the base64 data back to a PHP module for IE 🙂

    Using JQuery and PHP for a simple image (no slideshows… this was just my test-code) the code looks something like this:

    PHP:

    <?php    echo base64_encode(file_get_contents('image.jpg')); ?> 

    JS / JQuery:

    $(document).ready( function() {    $.get( 'image.php', function( data ) {       $(document).append('<img src=\'data:image/jpeg;base64,'+ data +'\'>');    }); }); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 91k
  • Answers 91k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Today Mono is quite mature in terms of performance and… May 11, 2026 at 6:13 pm
  • Editorial Team
    Editorial Team added an answer http://philip.html5.org/tests/canvas/suite/tests/ May 11, 2026 at 6:13 pm
  • Editorial Team
    Editorial Team added an answer You should close it as advised. And yes, if you're… May 11, 2026 at 6:13 pm

Related Questions

I have written this event photography application that features a slideshow among other things.
I'm using the ajax toolkit accordion extender and I notice it performs a little
Anyone know of a way to get your hands on a specific version of
I have a JavaScript method that I need to run on one of my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.