I'm not sure what is the proper way to do this.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zunebuggy
Forum Commoner
Posts: 41
Joined: Wed Aug 27, 2008 1:22 pm

I'm not sure what is the proper way to do this.

Post by zunebuggy »

After a user queries my database, if the query returns one or more results, I simply display the results. But if it returns zero results, I want the user to have the option of saving their search. This requires that on the if !$results, that I either print or echo a web page that includes the form to submit and save the query... OR do I have this page (with the form) already on my site and the if !$results simply redirects to that page. I just do not know which is best "netiquite" or which is best programatically? I want my site to have good flow and allow the users many logical options to get off pages without clicking the Back button. Thank you.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: I'm not sure what is the proper way to do this.

Post by onion2k »

Moved to PHP - Code.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: I'm not sure what is the proper way to do this.

Post by califdon »

zunebuggy wrote:After a user queries my database, if the query returns one or more results, I simply display the results. But if it returns zero results, I want the user to have the option of saving their search. This requires that on the if !$results, that I either print or echo a web page that includes the form to submit and save the query... OR do I have this page (with the form) already on my site and the if !$results simply redirects to that page. I just do not know which is best "netiquite" or which is best programatically? I want my site to have good flow and allow the users many logical options to get off pages without clicking the Back button. Thank you.
How do you plan to "save" the search terms? In a database? For how long? I don't understand the difference between your 2 approaches, they both sound the same to me. If your goal is to minimize the steps a user must take, I think I would not have a separate page at all. Presumably your user is already identified and you have the search terms, why not either have one button to click and save the data, or even just always save a search that returned no results, without even asking the user? And how do you plan to present previous no-results searches to the user? I don't think there's any netiquette issue involved. Just your concept of what you want your users to be able to do.
zunebuggy
Forum Commoner
Posts: 41
Joined: Wed Aug 27, 2008 1:22 pm

Re: I'm not sure what is the proper way to do this.

Post by zunebuggy »

Their query will be saved in a separate table in my database indexed by their unique unsername. After my If !$results statement, I adding what basically consists of an entire web page with a form, by using the echo command. It just seems like it is actually easier to create this page in HTML and use, I believe, the header command to redirect the user to this page? But I am not sure if this the correctway to do it?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: I'm not sure what is the proper way to do this.

Post by califdon »

zunebuggy wrote:Their query will be saved in a separate table in my database indexed by their unique unsername. After my If !$results statement, I adding what basically consists of an entire web page with a form, by using the echo command. It just seems like it is actually easier to create this page in HTML and use, I believe, the header command to redirect the user to this page? But I am not sure if this the correctway to do it?
Why do you need another web page and form? What other information would you ask the user for that you don't already have? If you are trying to make things easier for users, you shouldn't require additional operations unless there is something you need to store in the database that you don't already know.

You can't send a header to a browser after you have sent even one character, so you would need to use another method of redirecting, but again, I don't see why you need to do this.
Post Reply