How can I add a "loading" graphic to this page while my SELECT runs?

I've got a SELECT running that takes a while to complete.

I want to run a "spinner" graphic while the SELECT is cooking. I've found loading graphics that handle uploads and form submissions, but I don't see anything that addresses my situation specifically. Maybe I'm looking right at it and I just don't see it.

I'm retrieving about 4,000 rows. It takes about 15-20 seconds. How can I get a little animation to show while this is going on?
brucegustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
It's actually very simple.  Create a hidden element containing your graphic.  Add an 'onclick' action to the element that starts the SELECT that unhides the graphic.  The graphic sits and spins until the new page loads.  I see a lot of 'fancy' versions using AJAX but that's overly complicated.
mohan singhWeb developerCommented:
You can use ajax or JavaScript function for your requirements

use this link

also you can use
create page loader and include it where you want to use
and change url image of gif it will work

.loader {
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 114; 
    opacity: 1;
    backface-visibility: hidden; 
    background: url('gif/Wedges.gif') 50% 50% no-repeat rgb(249,249,249);
<div class="loader">
       	<!-- Javascript -->
	<script src="js/jquery-2.1.4.min.js"></script>
   <script type="text/javascript">
$(window).load(function() {

Open in new window

brucegustPHP DeveloperAuthor Commented:
Guys, I think we're poised on the threshold of great things, but here's the thing:

My user is going to click on a link that opens up another page. It's on that page where the loader needs to kick in. If I'm reading your recommendations correctly, it looks as though the route you're suggesting is a scenario where the user is on a page, clicks a button and the SELECT and the loader are initiated from that page as opposed to opening something up in a brand new session / window.

How do I get a loader to happen in an "onload" context and have it listening for the end of a PHP SELECT?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Dave BaldwinFixer of ProblemsCommented:
You don't.  The 'onload' doesn't happen until the page is loaded.  It also can not listen for the end or even existence of any PHP anything because it is JavaScript in the browser.  PHP will be done running before you even see it.  That's why you run it in the previous page so it will be on the screen until the new page loads.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brucegustPHP DeveloperAuthor Commented:
Got it!

Thank you, boys!
brucegustPHP DeveloperAuthor Commented:
What constituted the bottom line for me was understanding how the loading dynamic was actually a hidden div that was "shown" once you hit the link that opens the page you know is going to take a while to load. Once I understood that sequence, all was gold.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.