search keywords in all pages in my website

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

lvenkatesh
New php-forum User
New php-forum User
Posts: 4
Joined: Fri Jan 27, 2012 2:09 am
Location: Chennai,Tamilnadu,India

search keywords in all pages in my website

Postby lvenkatesh » Fri Oct 26, 2012 3:00 am

Hi,

I'm trying to build a simple search engine to my PHP site. I finished building my MySQL database, which includes 15 tables. Now I don't know how can I search words trough my database..

I want that when I search few words it will return me the name of tables which there exist in.

How can I do it?

Thanks in advance.

tkdbb84
New php-forum User
New php-forum User
Posts: 137
Joined: Tue Mar 08, 2011 9:25 am

Re: search keywords in all pages in my website

Postby tkdbb84 » Fri Oct 26, 2012 7:21 am

As far as I've ever seen you cannot search across multiple tables at once. (at least without using a join and there by losing the table the result came from). The only way to handle this would be to execute multiple queries, one on each table and search for the term across whatever fields you wish to search.

Select 1 from <table_1> WHERE <field_1> LIKE %<term>% AND <field_2> LIKE %<term>% ........
Select 1 from <table_2> WHERE <field_1> LIKE %<term>% AND <field_2> LIKE %<term>% ........

or if you are using a fulltext index you can use match against on multiple fields as well.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron