We have a page that is going to take about a minute or less to run a query and check various database stock levels.
While it's waiting and loading, is there a way to show a bit of text or image - basically echo ""; some content BEFORE the query is complete?
Regards
S.
How do you show HTML 'waiting' BEFORE DB Query is complete?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
How do you show HTML 'waiting' BEFORE DB Query is complete?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
You can do it in two ways -
1. flush the output buffer using flush() (and ob_flush() as necessary, read the description in the manual) to send output before the script has finished executing (ie, before you run the query)
2. Send an AJAX refresh after the page has loaded
If possible, it would be better to improve the performance of the queries / processes involved
1. flush the output buffer using flush() (and ob_flush() as necessary, read the description in the manual) to send output before the script has finished executing (ie, before you run the query)
2. Send an AJAX refresh after the page has loaded
If possible, it would be better to improve the performance of the queries / processes involved
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
In my experience, flushing doesn't always work. Since browsers generally show the current page while waiting for the new page to be generated & sent, I update the current page to say "Processing" or whatever.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
Thanks, but how do you update the page to say "processing" and for that to disappear when it is finished processing?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
I'm assuming you're submitting a form, and once the query is done, the page reloads.
You can use Javascript to put the words on the page before the form gets submitted, or make a hidden div appear, or however else you want to do it. Once the page reloads after the query is done, it's a different page so the "Processing" message shouldn't appear.
You can use Javascript to put the words on the page before the form gets submitted, or make a hidden div appear, or however else you want to do it. Once the page reloads after the query is done, it's a different page so the "Processing" message shouldn't appear.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
Very good idea, but I am not a Javascript writer. I can find them, and sometimes modify them. But sadly I cannot write Javascript from scratch.
Also not sure how Javascript would even be able to identify if a Query was completed?
Also not sure how Javascript would even be able to identify if a Query was completed?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
Do some research into how you can use Javascript to
- Listen for the submit() event of a form
- Make an hidden element appear on the page.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: How do you show HTML 'waiting' BEFORE DB Query is complete?
Use Ajax...simonmlewis wrote:Very good idea, but I am not a Javascript writer. I can find them, and sometimes modify them. But sadly I cannot write Javascript from scratch.
Also not sure how Javascript would even be able to identify if a Query was completed?
here is and example that you can read and with minors modifications incorporate to your page
http://www.w3schools.com/ajax/ajax_example.asp