Hi:
I'm looking for ideas about having a "please wait image" show up in my result page for a specified amount of time.
Basically I want to have my sponsor's ads display for several seconds before I show the requested information ... which is an image from our database.
The PHP code creates a table with a Search Results Display Cell in the middle of the table.. the other cells are ads.
I would like to display the "Please wait!" message in the center cell.. (preferably an animated image)
then let the ads show up and after 5 or so seconds.. replace the Please wait message with the image from their search request.
So to recap... I want to delay the search result to let the advertisers have more show time... and then TA DA.. the results of the search displays.
I'm using a mysql database. I execute php code to generate the results table from an html form that gets the details of the user's request.
I want to avoid any JAVA if I can. but I'll consider any suggestion.
Thanks
PLEASE WAIT MESSAGE
Moderator: General Moderators
Code: Select all
<meta http-equiv="refresh" content="10;url=http://www.yourdomain.com/">- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Better yet, make the results in a visible div and the ad in a hidden one, make the javascript flip them twice. That way users with no javascript will be able to see the results. Or, show both by default, let javascript hide and re-show the results, that way the non-js user will see both the ad and the results.arborint wrote:You could generate the results in a <div> that is not visible, and put the advert in a visible <div>. The have Javascript swap the visiblity after a specified time.
Could be a bit off-topic, but for those slow-running sql statements (or any other heavy function you might want to run), you can have a separate loading-screen to fetch all results, save them into session, and then redirect the user to another page after the sql statement is done running.
I didn't test the code below, and my apologies for any eventual syntax errors. I've been kicking around with ASP at my new job for a couple of weeks, and it's starting to get noticeable on my php-code
I didn't test the code below, and my apologies for any eventual syntax errors. I've been kicking around with ASP at my new job for a couple of weeks, and it's starting to get noticeable on my php-code
Code: Select all
<?php
session_start();
// Print a little loading message, animated gif/flash etc..
echo '<p>Please wait...</p>';
// Flush it out to the page
ob_flush();
flush();
// connect to a database etc..
$conn = mysql_connect('...');
mysql_select('...');
$rs = mysql_query('...');
// Temporary array to hold all our results
$results = array();
$i = 0;
// Dump all results into the temp array...
while($row == mysql_fetch_array($rs))
{
$results[$i] = $row['yourcolumn'];
$i++;
}
// and throw it into a session which we can access on the next page
$_SESSION['results'] = $results;
// And send the user to the page where the results will be shown (loaded from, for example, a session as above)
// document.location.replace is used to prevent the user from using the browser back-button to end up at the loading screen again.
echo '<script type="text/javascript">document.location.replace(\'show_results.php\');</script>';
// flush again
flush();
ob_flush();
?>