Re: [PHP-DB] Returning Results

2003-08-20 Thread Brent Baisley
I would advise making your search.php a function. This offers a lot 
of other flexibility.

On your searchform.php page just have an if() function to determine if 
any search parameters were passed. If there are parameters, perform the 
search. If there are results, display them, otherwise display the 
search form with a message that there were no results found.

Basically you are merging everything into one file and having a couple 
of conditional display areas. And if you use GET instead of POST in 
your form, the user can bookmark the resulting page.

On Tuesday, August 19, 2003, at 01:54 PM, Hutchins, Richard wrote:

OK, I'll apologize in advance if this is a little off topic, but I 
think
it'll be close enough.

I have a form (searchform.php) that collects data for a search (e.g.,
firstname, lastname). That form submits to a separate PHP script
(search.php) that queries a database to find matching rows and returns 
the
information in an array ($results).

All pretty standard stuff and it all works.

I know I while() the information in the resulting array ($results) 
to draw
a table showing all of the results. But what that would require is the 
form
(searchform.php) to collect the data and submit to the search.php 
script
where HTML and PHP code combine in one file to perform the query and 
draw
the results. I know how to do this and have done it in the past.

However, this instance has a wrinkle to it. When the searchform.php 
form
submits to search.php, I want to perform the query, but return the 
user (and
the $results array) to searchform.php to display the results.

I want to stress that I can get the information from the database with 
no
problem. I'm just stuck on how to get the results back to the page that
called the search.php script in the first place.

Is turning search.php into a function and return-ing the results the 
only
way to accomplish this? Because the only other idea I can come up with 
is
using a header(Location:http://searchform.php?rs=$results;); 
statement and
that doesn't seem to work (and logically, I can see why).

I'm not asking for a total solution here because I can handle the whole
solution myself. However I would appreciate a bump in the right 
direction in
regards to how to architect the application logic.

Thanks in advance,
Rich
Rich Hutchins

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

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Returning Results

2003-08-19 Thread Aaron Wolski
Hi Richard,

When you submit the form, why not have a hidden field in the form like:

input type=hidden name=backtopage value=?php echo
$_SERVER['PHP_SELF']; ?

Then use that 'backtopage' variable in your script where you direct the
results to.

Or.. if you don't want to use a hidden field.. parse the URL to get the
referrer?

HTH

Aaron

 -Original Message-
 From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
 Sent: August 19, 2003 1:54 PM
 To: PHP-DB
 Subject: [PHP-DB] Returning Results
 
 OK, I'll apologize in advance if this is a little off topic, but I
think
 it'll be close enough.
 
 I have a form (searchform.php) that collects data for a search (e.g.,
 firstname, lastname). That form submits to a separate PHP script
 (search.php) that queries a database to find matching rows and returns
the
 information in an array ($results).
 
 All pretty standard stuff and it all works.
 
 I know I while() the information in the resulting array ($results)
to
 draw
 a table showing all of the results. But what that would require is the
 form
 (searchform.php) to collect the data and submit to the search.php
script
 where HTML and PHP code combine in one file to perform the query and
draw
 the results. I know how to do this and have done it in the past.
 
 However, this instance has a wrinkle to it. When the searchform.php
form
 submits to search.php, I want to perform the query, but return the
user
 (and
 the $results array) to searchform.php to display the results.
 
 I want to stress that I can get the information from the database with
no
 problem. I'm just stuck on how to get the results back to the page
that
 called the search.php script in the first place.
 
 Is turning search.php into a function and return-ing the results the
 only
 way to accomplish this? Because the only other idea I can come up with
is
 using a header(Location:http://searchform.php?rs=$results;);
statement
 and
 that doesn't seem to work (and logically, I can see why).
 
 I'm not asking for a total solution here because I can handle the
whole
 solution myself. However I would appreciate a bump in the right
direction
 in
 regards to how to architect the application logic.
 
 Thanks in advance,
 Rich
 
 Rich Hutchins
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




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



RE: [PHP-DB] Returning Results

2003-08-19 Thread Hutchins, Richard
Thanks for the response, Aaron. But my problem isn't finding out who the
referrer was. My problem is how to get the results of the database query
back to the referrer without using any html. I think I need to get it into
the request somehow.

I'm probably making things wy more difficult than they NEED to be for
myself, but my goal is to have the application logic, in this case the query
script, totally separate from the presentation layer (the html).

You know, ideally, I'd like to do something like the following pseudocode:

while($row = mysql_fetch_array($results)){
$_POST['id'] = $row['id'];
$_POST['firstname'] = $row['firstname'];
$_POST['lastname'] = $row['lastname'];
}
header(Location:http://www.mysite.org/searchform.php;);

And that would set the $_POST variables in the request without having any
HTML. I guess I should probably just try it seeing as I've already typed it
out, but I've never stumbled across anything like this before and wanted to
see if there was already a tried and true method for accomplishing it.

Ugh. I feel the headache coming on.

 -Original Message-
 From: Aaron Wolski [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 19, 2003 2:00 PM
 To: 'Hutchins, Richard'; 'PHP-DB'
 Subject: RE: [PHP-DB] Returning Results
 
 
 Hi Richard,
 
 When you submit the form, why not have a hidden field in the 
 form like:
 
 input type=hidden name=backtopage value=?php echo
 $_SERVER['PHP_SELF']; ?
 
 Then use that 'backtopage' variable in your script where you 
 direct the
 results to.
 
 Or.. if you don't want to use a hidden field.. parse the URL 
 to get the
 referrer?
 
 HTH
 
 Aaron
 
  -Original Message-
  From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
  Sent: August 19, 2003 1:54 PM
  To: PHP-DB
  Subject: [PHP-DB] Returning Results
  
  OK, I'll apologize in advance if this is a little off topic, but I
 think
  it'll be close enough.
  
  I have a form (searchform.php) that collects data for a 
 search (e.g.,
  firstname, lastname). That form submits to a separate PHP script
  (search.php) that queries a database to find matching rows 
 and returns
 the
  information in an array ($results).
  
  All pretty standard stuff and it all works.
  
  I know I while() the information in the resulting array ($results)
 to
  draw
  a table showing all of the results. But what that would 
 require is the
  form
  (searchform.php) to collect the data and submit to the search.php
 script
  where HTML and PHP code combine in one file to perform the query and
 draw
  the results. I know how to do this and have done it in the past.
  
  However, this instance has a wrinkle to it. When the searchform.php
 form
  submits to search.php, I want to perform the query, but return the
 user
  (and
  the $results array) to searchform.php to display the results.
  
  I want to stress that I can get the information from the 
 database with
 no
  problem. I'm just stuck on how to get the results back to the page
 that
  called the search.php script in the first place.
  
  Is turning search.php into a function and return-ing the 
 results the
  only
  way to accomplish this? Because the only other idea I can 
 come up with
 is
  using a header(Location:http://searchform.php?rs=$results;);
 statement
  and
  that doesn't seem to work (and logically, I can see why).
  
  I'm not asking for a total solution here because I can handle the
 whole
  solution myself. However I would appreciate a bump in the right
 direction
  in
  regards to how to architect the application logic.
  
  Thanks in advance,
  Rich
  
  Rich Hutchins
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

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