July 26th, 2000, 09:02 AM
how can i search within the results of a mysql query with php?
July 26th, 2000, 09:47 AM
i dont think you can, just add an AND blah blah blah on the end of the query.
if there is a way, id like to know too.
July 26th, 2000, 11:08 AM
What kind of stuff would you want to search.
I suppose you could loop through your result set and add things to an arrya based on some criteria, but then again you could do that in your original query, could you be more specific about what you are looking to do.
July 26th, 2000, 11:44 AM
i cant do this in one query because i would like to create the following situation:
a user searches my database for information. He gets a result and then would like to search with another term in the result to get fewer results that match his desires more precisely. know what i mean?
could i do this with an array and a loop? how?
July 26th, 2000, 12:58 PM
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>a user searches my database for information. He gets a result and then would like to search with another term in the result to get fewer results that match his desires more precisely[/code]
Can't you just use the variables passed on the first time? let's assume a first search:
you show the results and I assume you have some field where a user can further define his search. include the variabeles above as hidden variables and let the user add a new constraint:
since the list was very long, he wants only the italian restaurants:
extra variable: $food=italian
new query to database:
bla bla WHERE t=r AND c=e AND f=i
This would do it, wouldn't it
Hope this makes some sense!
July 26th, 2000, 01:01 PM
I would say that the easiest way to do this is to display the results from the inital query with another search box at the top with his original searchterm as a hidden input in the search form. So when he resubmits the form you could make your select statement on the fly to include his first searchword and his second. so the first query might be like
SELECT * from tablename WHERE field like '%$searchword%';
then when he resubmits you could make your sql query something like
SELECT * from tablename WHERE (field like '%$searchword1%') AND (field like '%$searchword2%');
Where searchword1 is the value of your hidden input.
July 26th, 2000, 01:07 PM