[PHP] Database search logic question
For those who recognize this topic from me and perhaps are sick of it , my apologies :) This is actually a different question more about logic then syntax or functionality. One of the uses of my search form is that users may save their search parameters. Typical benefits, they don't have to re-enter all the criteria. Hitting one link or receiving an email can get them the results they need. The way I was approaching this was to grab the url, the part after the ? , so not the referer. Whatever the second part is called. Only now that I've created a search and results page via Post method, of course there is nothing going to the URL. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. Curious if anyone sees benefits or negatives with either. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
A couple of possibilities are: Store search criteria (form entries) in MySQL Store query string in MySQL If the user has to log-in then the MySQL table would be keyed on the user_id or similar. If the user does not have to log-in then you will most likely need to store something in a client-side cookie that references the saved query details. On one of my sites I allow users to either build a query via a step-by-step procedure or manually enter a query statement. It is the statement that I store in the database together with a name they supply and their user id. This allows the user to save multiple queries and recall them at a later date by a name that they supplied. HTH Graham -Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: 15 November 2004 09:10 To: [EMAIL PROTECTED] Subject: [PHP] Database search logic question For those who recognize this topic from me and perhaps are sick of it , my apologies :) This is actually a different question more about logic then syntax or functionality. One of the uses of my search form is that users may save their search parameters. Typical benefits, they don't have to re-enter all the criteria. Hitting one link or receiving an email can get them the results they need. The way I was approaching this was to grab the url, the part after the ? , so not the referer. Whatever the second part is called. Only now that I've created a search and results page via Post method, of course there is nothing going to the URL. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. Curious if anyone sees benefits or negatives with either. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
Please see inline: --- Graham Cossey [EMAIL PROTECTED] wrote: A couple of possibilities are: Store search criteria (form entries) in MySQL Store query string in MySQL So with my current form, the where statement is built from conditions that are set (or not set) in the form. Perhaps I grab that one array ? On one of my sites I allow users to either build a query via a step-by-step procedure or manually enter a query statement. It is the statement that I store in the database together with a name they supply and their user id. This allows the user to save multiple queries and recall them at a later date by a name that they supplied. I have something like that set up now. The user must be registered and logged in, the difference is I'm saving the query string from URL. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
-Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: 15 November 2004 10:12 To: Graham Cossey; [EMAIL PROTECTED] Subject: RE: [PHP] Database search logic question Please see inline: --- Graham Cossey [EMAIL PROTECTED] wrote: A couple of possibilities are: Store search criteria (form entries) in MySQL Store query string in MySQL So with my current form, the where statement is built from conditions that are set (or not set) in the form. Perhaps I grab that one array ? [snip] I was thinking more along the lines of storing the SQL string. SELECT ... FROM vendorjobs WHERE... Then when recalled there is no further array processing etc to be done. However, you may want some kind of validation to prevent malicious use of the feature. I've never attempted to store an array in a MySQL table. But storing the 'where' is an alternative. Other guys (and girls) on the list probably have much more experience of this than myself. Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
Stuart Felenstein mailto:[EMAIL PROTECTED] on Monday, November 15, 2004 1:10 AM said: The way I was approaching this was to grab the url, the part after the ? , so not the referer. This sounds like you're not familiar with the $_GET array. $_GET is everything after the ? in the url but as an array. Whatever the second part is called. I *think* that's the querystring. Not sure on that though. Only now that I've created a search and results page via Post method, of course there is nothing going to the URL. This sounds like you're not familiar with the $_POST array. $_POST is everything that *would be* after the ? in the url but as an array. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. I don't see how these two things are similar. shrugs If you want to store your array in a db use serialize() and unserialize(). In any case I would just store the search criteria in a cookie and leave the db out of it. HTH, Chris. * http://www.php.net/serialize http://www.php.net/unserialize -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database search logic question
On Mon, 15 Nov 2004 09:21:01 -0800, Chris W. Parker [EMAIL PROTECTED] wrote: This sounds like you're not familiar with the $_GET array. $_GET is everything after the ? in the url but as an array. Whatever the second part is called. I *think* that's the querystring. Not sure on that though. $_SERVER['QUERY_STRING'] to be exact. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database search logic question
On November 15, 2004 13:27, Stuart Felenstein wrote: See inline: --- Chris W. Parker [EMAIL PROTECTED] wrote: Stuart Felenstein mailto:[EMAIL PROTECTED] on Monday, November 15, 2004 1:10 AM said: The way I was approaching this was to grab the url, the part after the ? , so not the referer. This sounds like you're not familiar with the $_GET array. $_GET is everything after the ? in the url but as an array. It sounds like you answered before you either read or understood. I was talking about $_SERVER[QUERY_STRING]; This sounds like you're not familiar with the $_POST array. $_POST is everything that *would be* after the ? in the url but as an array. In $_POST there is nothing in the URL , there is no ?. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. I don't see how these two things are similar. shrugs They are not similar but will accomplish the same goal. If you want to store your array in a db use serialize() and unserialize(). In any case I would just store the search criteria in a cookie and leave the db out of it. A ccokie wouldn't help me one bit in this situation. Stuart Stuart, Did you take the time to think about what you were going to do before starting your application? You are asking more than one question within this newest version of your thread and are treating people's responses to each individual question as part of one all encompassing answer. If you are looking to have the SQL query string sent as POST vars but don't know how to get those out of the array, I would say you have some RTFMing to do, the same would go for sending the users to your results page AND ( you can do both POST and GET vars for a single page) adding a querystring to the url so that the user could bookmark the url and have a way to return to the same query they specified provided that the database query happens on/in the results page. If that answers any of your questions, great, if not, try planning ahead a little instead of asking the list to write the functionality code for you. -- Regards, David Bevan We could learn a lot from crayons: some are sharp, some are pretty, some are dull, some have weird names, and all are different colorsbut they all exist very nicely in the same box. http://www.getanyideas.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Database search logic question
Hello Stuart, Monday, November 15, 2004, 6:27:18 PM, you wrote: SF In $_POST there is nothing in the URL , there is no ?. Technically, there can be. You can post a form to x.php?foo=bar and it will populate both the POST and GET super-globals. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. SF They are not similar but will accomplish the same SF goal. Given than URLs change over time, surely it would make sense to save the actual search parameters instead, so then you could re-build the search even if the URL of it changed. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
See inline: --- Chris W. Parker [EMAIL PROTECTED] wrote: Stuart Felenstein mailto:[EMAIL PROTECTED] on Monday, November 15, 2004 1:10 AM said: The way I was approaching this was to grab the url, the part after the ? , so not the referer. This sounds like you're not familiar with the $_GET array. $_GET is everything after the ? in the url but as an array. It sounds like you answered before you either read or understood. I was talking about $_SERVER[QUERY_STRING]; This sounds like you're not familiar with the $_POST array. $_POST is everything that *would be* after the ? in the url but as an array. In $_POST there is nothing in the URL , there is no ?. I'm wondering at this point if I should create a way to let users save their search parameters, by grabbing the variables and storing them as an array in the database or go back to the URL method. I don't see how these two things are similar. shrugs They are not similar but will accomplish the same goal. If you want to store your array in a db use serialize() and unserialize(). In any case I would just store the search criteria in a cookie and leave the db out of it. A ccokie wouldn't help me one bit in this situation. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database search logic question
See inline please: --- David Bevan [EMAIL PROTECTED] wrote: Did you take the time to think about what you were going to do before starting your application? Honestly , no I did not. What I did start out with is a belief that there wouldn't be a need to know php. I was using a RAD, that was sold as all encompassing. Fool me once. If you are looking to have the SQL query string sent as POST vars but don't know how to get those out of the array, I would say you have some RTFMing to do, the same would go for sending the users to your results page AND ( you can do both POST and GET vars for a single page)adding a querystring to the url so that the user could bookmark the url and have a way to return to the same query they specified provided that the database query happens on/in the results page. Ok, I was not aware that both POST and GET can be used at the same time. If that answers any of your questions, great, if not, try planning ahead a little instead of asking the list to write the functionality code for you. Okay, so showing me how something works is now wrong ? No one has shown you code or explained a better method at some function ? This particular post has went way passed its course. Thank you for your help. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
Did you take the time to think about what you were going to do before starting your application? Honestly , no I did not. What I did start out with is a belief that there wouldn't be a need to know php. I was using a RAD, that was sold as all encompassing. Fool me once. Yeah, that's always fun. You think you're getting something close to what you want, maybe with some tweaking, and what you end up with is really a giant spaghetti tangle of unusable code that you have no choice but to hack enough to get a functional product. Or re-write the whole thing by hand. Don't worry.. Questions are good, but do your best to untangle what you can, get all your questions together and hit the web sites and mailing lists. The more research you do and more helping yourself you do, the less RTFM and othe responses similar to what you got above. But hell... It's not like the rest of us have never ended up neck-deep in a mess that we needed as much help as we could get to untangle. If you are looking to have the SQL query string sent as POST vars but don't know how to get those out of the array, I would say you have some RTFMing to do, the same would go for sending the users to your results page AND ( you can do both POST and GET vars for a single page)adding a querystring to the url so that the user could bookmark the url and have a way to return to the same query they specified provided that the database query happens on/in the results page. Ok, I was not aware that both POST and GET can be used at the same time. Yeah, you can do that. GET requests are just where the info is passed via the URL. You don't even need a FORM to do GET variables. Just do scriptname.php?getvar1=Testgetvar2=Test2 Then use $_GET[getvar1] or whatever you named them. You can also use $_REQUEST[] to get any data put into $_GET, $_POST or $_COOKIE (superceding in that order I believe.. That is, it gets all the GET data first, and if there's a POST variable of the same name, it overwrites the GET version... And COOKIE overwrites POST). If that answers any of your questions, great, if not, try planning ahead a little instead of asking the list to write the functionality code for you. Okay, so showing me how something works is now wrong ? No one has shown you code or explained a better method at some function ? This particular post has went way passed its course. Thank you for your help. Probably...Understand that there are a lot of people on here who post a lot of responses and help a lot of people and they have bad days just like everyone else. So while you ask for patience and consideration for your questions, be sure to show some patience and consideration for those who bother to respond. It's a two-way street. I mean, if people got nasty every time someone asked a question that was answered with YOU HAVE REGISTER GLOBALS TURNED OFF NOW!! or other questions that we all probably ran into when we were starting out ourselves, then we'd have a lot of flaming going on here. This is a PHP General mailing list, it should be for general, newbie, etc sort of questions. But the expectation is that the questions being asked were researched some ahead of time as well. Although that's not always an option and that needs to be understood as well. Good luck, Stuart. -TG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database search logic question
--- Gryffyn, Trevor [EMAIL PROTECTED] wrote: This is a PHP General mailing list, it should be for general, newbie, etc sort of questions. But the expectation is that the questions being asked were researched some ahead of time as well. Although that's not always an option and that needs to be understood as well. Good luck, Stuart. -TG Thank you Trevor. Your words will be well heeded. Your effort and response is greatly appreciated. I'm going to make a better effort going forward before turning to the list for quick answers. I've received many great answers and explanations here. All have been appreciated , and I hope used for the betterment of right now, at least my understanding. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php