RE: [PHP] intermediate search screen
| From: | John W. Holmes | Date: | Thu, 10 Apr 2003 00:22:10 +0000 |
| Subject: | RE: [PHP] intermediate search screen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143241@lists.php.net to get a copy of this message | ||
> thats the thing, ok theroetically , i'd like to post to say
>
> search.php
OK
> a screen shows up saying please wait , or to be fancy a progress bar
:D,
> and
> as it is doing this it is quering the database for the results,
instead of
> looking like its hanging on a white screen somehow doing the query in
the
> background , and when the resultset is done redirect to the results
page ,
> would i have to store the results into and array, redirect and then
loop
> throug the array to show the results ?
No... You can't show some text on a page and then execute some PHP code
to do your search... Remember how PHP works. By the time the browser
loads, the PHP code is done.
> say i had 100,000 records which is what i am gonna have to search upon
> full
> text !, its gonna take a while to get all the results within a while
loop,
> i
> cannot seem to get a screen up there while its looping and then
redirect
> when
> its finished, somehow flush it while its looping then redirect when
its
> finished the resultset any ideas ? i cannot seem to echo anything
until
> the
> loop is finished well in PHP3 anyway , 4 i can ob_flush it
You need three pages (or three sections in the same page). Say you have
a form with just a single text box that you're going to search your
database with:
Search Page:
-----------
<form method="POST" action="intermediate.php">
<input type="text" name="word">
<input type="submit" value="Search">
</form>
Intermediate Page:
-----------------
<html>
<head>
<title>Processing...</title>
<meta http-equiv="refresh"
content="1;url=http://www.yoursite.com/results.php?word=<?=urlencode($_P
OST['word'])?>">
</head>
<body>
Processing your search... Please wait.
</body>
</html>
Results Page:
------------
<?
$query = "SELECT * FROM table WHERE text LIKE '%{$_GET['word']}%'";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
foreach($row as $e)
{ echo "$e -- "; }
}
?>
Hope that helps... :)
---John Holmes...