#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    how can i search within the results of a mysql query with php?

    pieter
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    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.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    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.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    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?
  8. #5
  9. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    <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:

    $topic=restaurants
    $city=enschede
    (search.php?$topic=restaurants&$city=enschede)

    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:

    2nd search:
    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!

    Mirax
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    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.
  12. #7
  13. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    lol

Similar Threads

  1. simple search query
    By SeenGee in forum PHP Development
    Replies: 1
    Last Post: February 10th, 2004, 01:30 PM
  2. Replies: 2
    Last Post: January 28th, 2004, 08:07 AM
  3. Cgi Search feature script
    By butsy_7 in forum Perl Programming
    Replies: 5
    Last Post: January 22nd, 2004, 08:43 PM
  4. How can I perform a search with a previous search results?
    By charlie_tango in forum MySQL Help
    Replies: 1
    Last Post: January 17th, 2004, 11:06 AM
  5. Overwriting mysql query with the query results
    By onerandomday in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2004, 05:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo