[PHP] Thoughts on a simple search engine...

2002-09-24 Thread Chuck Payne

Ok for a simple search I should be able to create a form page and Enter the
value and select the feild that Ron want to search.

Example

$sql = SELECT * FROM \$table\ WHERE \$field\ LIKE \'%$value%'\ ORDER
BY \$input\;

$table = Of course the table they want to search
$field = Field that want to seach
$value = value what they want to by
$input = if they want to search by something other a node numder.

So I if I create the form, is there way that I can have it echo on the same
page if I am using a form?


Chuck Payne
Magi Design and Support



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Thoughts on a simple search engine...

2002-09-24 Thread Support @ Fourthrealm.com

Chuck,
Setup your form like this (assuming search.php is the name of your page):

FORM ACTION=search.php METHOD=post
INPUT TYPE=hidden NAME=step VALUE=2
.
/FORM


Then in your search.php page, use this structure:

# --- set $step to passed value, or else set to default ---
if (isset($_GET[step]))   { $step=$_GET[step]; }
elseif (isset($_POST[step]))  { $step=$_POST[step]; }
else{ $step=1; }


if ($step==2)
{
 # --- do the Search query and display results here ---


 # after displaying, then set step=1  to force the search form to 
come up again at the bottom of the page
 $step=1;
}

if ($step==1)
{
 # --- put the form here...  ---
}


I use the step variable all the time in controlling page flow, and 
allowing me to re-use the same .php file for many similar purposes to keep 
the file count of the site low.

HTH,

Peter



At 02:13 PM 9/24/2002 -0500, Jay Blanchard wrote:
[snip]
So I if I create the form, is there way that I can have it echo on the same
page if I am using a form?
[/snip]

Yes, using $PHP_SELF as your form action

HTH

Jay

Ever stop to think, and forget to start again?

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort  Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

- - - - - - - - - - - - - - - - - - - - -
Fourth Realm Solutions
[EMAIL PROTECTED]
http://www.fourthrealm.com
Tel: 519-739-1652
- - - - - - - - - - - - - - - - - - - - -


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php