0

I have a basic search form with 5 dropdown menu and I want it to search 2 database content and display it in a result page. I have not done this before and there is almost nothing to guide me on the internet. I am looking to build a result.php page. The database names are tours and departures. Tours table: code, operator, duration, overview, image, tour_style Departures Table: code, operator, start_date, end_date, price, status All help is greatly appreciated

user1342542
  • 15
  • 1
  • 5

1 Answers1

0

I have made a search form using php and mysql (for single database) for my website. i used MATCH and AGAINST in mysql command syntax. These are some useful links which may help you for making your search form.

http://devzone.zend.com/26/using-mysql-full-text-searching/#Heading12

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

http://forums.digitalpoint.com/showthread.php?t=27529

http://www.seopher.com/articles/tutorial_mysql_fulltext_searching

eg:

SELECT *
    FROM tours
    WHERE  MATCH ( code,operator,duration, overview, image, tour_style  )
    AGAINST (  '%$keywords%' );

I have tried this only for one database and it worked perfectly for me. I am not sure about creating search form for two database. May be you can create two mysql Match queries one for tours and other for departures, like this..

SELECT *
    FROM tours
    WHERE  MATCH ( code,operator,duration, overview, image, tour_style  )
    AGAINST (  '%$keywords%' );
SELECT *
    FROM departures
    WHERE  MATCH ( code, operator, start_date, end_date, pricecode, operator, start_date, end_date, price )
    AGAINST (  '%$keywords%' );

Please search google thoroughly..

Disclaimer: Didn't tried above MySQL codes in a machine, as i dont have mysql installed in this machine

Eka
  • 14,170
  • 38
  • 128
  • 212
  • Thanks test,I really appreciate your help, and the links too but the sql statements gave error messages. I guess it has to be something that can join both tables all at once. Do you have any further ideas. Please let me know. Thanks. – user1342542 Apr 19 '12 at 14:47
  • Thanks Test for your quick response. – user1342542 Apr 19 '12 at 14:48
  • can you tell me what error it showed? i will try to find a solution for this – Eka Apr 20 '12 at 05:39
  • Thanks again for your kind response. Yes the code,-it selected everything, you know I had the individual search parameters with else if statements and finally an else statement if nothing is selected so the submit button reads just the last else statement. This is the scenario. In the search form, the options are dynamically populated from both tables-Operator: Tour Style: Start Date: Tour Length: and Tour Price:. Now if a user selects a tour operator, a particular tour style, start date, tour length or price range, I want the display to search as per user's search parameter. – user1342542 Apr 20 '12 at 13:32
  • This is above my current programming skills, please post another question regarding your above comment in this forum..again sorry for not answering your query – Eka Apr 21 '12 at 06:04