Forum Moderators: coopster
Right now, if people want to search for "berry", they would have to go to my A database to search for it. Then if they want to search for "berry" from my B database, they would have to go there to search. So it's very inconvenient. I know I could just incorporate all the databases together into one big database, but I don't want to do that.
I hope I haven't lost anyone yet. Does anyone have any idea of doing that? Thanks.
if you have multiple databases in the same "database" (e.g. mySQL), then you can use
mysql_choose_db("database_name1");
// do query
mysql_choose_db("database_name2");
// do another query
If you have multiple tables in the same database, then as mentioned above you can try a JOIN or UNION or something. I am hardly capable of giving advice on that subject... Hopefully someone will jump in with a solution, if there is one.
Regardless of the method you use to grab the hits, you will want to "mix" and sort the results by relevance. If there is a way to do it with just SQL, then do that! But it's easier to do in PHP, once you've grabbed all the close hits and thrown them into an array.
$hits[0]['URL']="http://yaddayadda"
$hits[0]['title]="this is my page"
$hits[0]['relevance']=95.4
$hits[1]['URL']="http://hupnahupna"
$hits[1]['title]="this is your page"
$hits[1]['relevance']=17.0
then you can sort the array by relevance, and show them in order.
If searching is really key to the functionality to your site, you could also set up another table that just has all the information from your other tables that you want searchable in one field, and an identifier or url in another field corresponding to the page all that info is on. This could use a fulltext index for better search relevance. It'll use a lot of hard disk space, but hard disk space is cheap these days.