PLEASE WAIT MESSAGE

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
savri
Forum Newbie
Posts: 3
Joined: Fri Nov 24, 2006 9:31 am

PLEASE WAIT MESSAGE

Post by savri »

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
skruby
Forum Newbie
Posts: 10
Joined: Thu Nov 23, 2006 2:32 pm

Post by skruby »

That sounds like a job for Javascript.


First: display the ad
setTimeout(5 secs) then toggle() the ad and show your results
savri
Forum Newbie
Posts: 3
Joined: Fri Nov 24, 2006 9:31 am

Post by savri »

I'm not very slick with java and want to avoid blockers!
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

<meta http-equiv="refresh" content="10;url=http://www.yourdomain.com/">
savri
Forum Newbie
Posts: 3
Joined: Fri Nov 24, 2006 9:31 am

Post by savri »

Are you suggesting that I first generate my results with a page that has the refresh in it and then regenerate it with the actual results?

If so I'm not sure how the variables are passed to the actual request through the refress process? Or am I not getting your suggestion at all?

Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

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.
(#10850)
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

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.
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.
User avatar
Hurreman
Forum Commoner
Posts: 61
Joined: Sat Apr 29, 2006 8:42 am

Post by Hurreman »

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 :oops:

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();
?>
Post Reply