Please Wait Message
Moderator: General Moderators
Please Wait Message
Hi,
I have a php script which runs a query that takes ages to run, so I'd like to tell the user to "please wait"
I've tried putting a message in and echoing it out before the query, but nothing gets displayed until the query is run.
Can anyone help?
Many thanks
RedRasper
I have a php script which runs a query that takes ages to run, so I'd like to tell the user to "please wait"
I've tried putting a message in and echoing it out before the query, but nothing gets displayed until the query is run.
Can anyone help?
Many thanks
RedRasper
i think this might be some use http://se.php.net/manual/en/function.flush.php
basically, it "flushes" all output so far to the broswer. So placing it after the echo command should work.
You may need more help with this cos certain browers have certain problem doing this.
Make sure you read all the notes on the link i gave you.
Mark
basically, it "flushes" all output so far to the broswer. So placing it after the echo command should work.
You may need more help with this cos certain browers have certain problem doing this.
Make sure you read all the notes on the link i gave you.
Mark
Hi,
thanks for the reply, that looks like its going to get some output. I'm going to play with that now.
Just a slight modification on the question though, can I have a loading page saying "executing query" then when that has finished clear that off the screen and display the query results?
Many thanks
RedRasper
thanks for the reply, that looks like its going to get some output. I'm going to play with that now.
Just a slight modification on the question though, can I have a loading page saying "executing query" then when that has finished clear that off the screen and display the query results?
Many thanks
RedRasper
Yes that is possible.
Don't know if you have ever used Streamload (http://www.streamload.com), but the thing you are describing happens on that site!
I think it is done using <div> tags and CSS.
Not 100% sure though.
Don't know if you have ever used Streamload (http://www.streamload.com), but the thing you are describing happens on that site!
I think it is done using <div> tags and CSS.
Not 100% sure though.
**Removed due to errors in scripts**
Last edited by JayBird on Wed Sep 03, 2003 6:35 am, edited 1 time in total.
ignore my previous post, i didn't work, i have now refined it.
Try this fully working example (save the file with a .php extension)
Mark
Try this fully working example (save the file with a .php extension)
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language=JavaScript>
function getPageItem(itemID)
{
if (document.getElementById)
{
return document.getElementById(itemID);
}
if (document.all)
{
return document.allїitemID];
}
return null;
}
<!--
function slUpdateSpan(newHtml)
{
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj)
{
if (span_obj.style.display != "inline")
{
span_obj.style.display = "inline";
}
span_obj.innerHTML = newHtml;
}
}
function killUpdateSpan()
{
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj)
{
span_obj.style.display = "none";
}
}
//-->
</script>
</head>
<body>
<div id="idUpdateableSpan"
style="position: absolute;
top: 40%; left: 35%;
width: 30%;
height: 80px;
filter:alpha(opacity=80);
-moz-opacity:80%;
margin:0;
padding:15px;
background-color:#eee;
border:1px solid #333;
text-align: center;
z-index:1000;
display:none;
cursor:default;
"></div>
<script language=JavaScript>
<!--
slUpdateSpan("Yawning...<br><br>");
//-->
</script>
<? flush(); sleep(5); ?>
<script language=Javascript>
<!--
killUpdateSpan();
//-->
</script>
</body>
</html>you can also change the message at different stages
Save this code with a .php extension
Mark
Save this code with a .php extension
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language=JavaScript>
function getPageItem(itemID)
{
if (document.getElementById)
{
return document.getElementById(itemID);
}
if (document.all)
{
return document.allїitemID];
}
return null;
}
<!--
function slUpdateSpan(newHtml)
{
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj)
{
if (span_obj.style.display != "inline")
{
span_obj.style.display = "inline";
}
span_obj.innerHTML = newHtml;
}
}
function killUpdateSpan()
{
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj)
{
span_obj.style.display = "none";
}
}
//-->
</script>
</head>
<body>
<div id="idUpdateableSpan"
style="position: absolute;
top: 40%; left: 35%;
width: 30%;
height: 80px;
filter:alpha(opacity=80);
-moz-opacity:80%;
margin:0;
padding:15px;
background-color:#eee;
border:1px solid #333;
text-align: center;
z-index:1000;
display:none;
cursor:default;
"></div>
<script language=JavaScript>
<!--
slUpdateSpan("Yawning...<br><br>");
//-->
</script>
<? flush(); sleep(5); ?>
<script language=JavaScript>
<!--
slUpdateSpan("Preparing to continue...<br><br>");
//-->
</script>
<? flush(); sleep(5); ?>
<script language=Javascript>
<!--
killUpdateSpan();
//-->
</script>
</body>
</html>another variation if you are interested.
Again, just save the script with a .php extension
Again, just save the script with a .php extension
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language=JavaScript>
function getPageItem(itemID) {
if (document.getElementById) {
return document.getElementById(itemID);
}
if (document.all) {
return document.allїitemID];
}
return null;
}
<!--
function slUpdateSpan(newHtml) {
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj) {
if (span_obj.style.display != "inline") {
span_obj.style.display = "inline";
}
span_obj.innerHTML = newHtml;
}
}
function killUpdateSpan() {
var span_obj = getPageItem("idUpdateableSpan");
if (span_obj) {
span_obj.style.display = "none";
}
}
//-->
</script>
</head>
<body>
<div id="idUpdateableSpan"
style="position: absolute;
top: 40%; left: 35%;
width: 30%;
height: 80px;
filter:alpha(opacity=80);
-moz-opacity:80%;
margin:0;
padding:15px;
background-color:#eee;
border:1px solid #333;
text-align: center;
z-index:1000;
display:none;
cursor:default;
"></div>
<script language=JavaScript>
<!--
slUpdateSpan("Yawning...<br><br>");
//-->
</script>
<? flush(); sleep(5); ?>
<?
$i = 0;
while ($i < 10) {
echo "<script language=JavaScript>\n";
echo "<!--\n";
echo " slUpdateSpan("Putting the cat out".str_repeat(".", $i)."<br><br>");\n";
echo "//-->\n";
echo "</script>\n";
flush(); sleep(1);
$i++;
}
?>
<script language=Javascript>
<!--
killUpdateSpan();
//-->
</script>
</body>
</html>