Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 05:42:34 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149667 Posts in 21100 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Guestbook and searching  (Read 1653 times)
Achrist

Offline Offline

Posts: 37


« on: December 27, 2007, 10:06:10 AM »

If you add - as I have done - Guestbook section to several pages - then an the way searching is constructed generates erroneus results (way too many). The reason is this. Guestbook enters the following code into the Search table:

SELECT [TP]pages.page_id, [TP]pages.page_title,    [TP]pages.link    FROM [TP]mod_guestbook, [TP]mod_guestbook_setti ngs, [TP]pages WHERE [TP]pages.page_id = [TP]mod_guestbook_setti ngs.page_id AND [TP]mod_guestbook.name
  • \'[W][STRING][W]\' .... etc.

It is not clear to me why mod_guestbook_setti ngs is referenced here, and the result is that if there is a search match in one of the mod_guestbook columns, then all pages pointed to by mod_guestbook_setti ngs.page_id are returned as hits. This, of course, is wrong.

I suggest the following code instead (removing mod_guestbook_setti ngs and linking pages and mod_guestbook on page_id instead)

query_start:
SELECT [TP]pages.page_id, [TP]pages.page_title,    [TP]pages.link    FROM [TP]mod_guestbook, [TP]pages WHERE

query_body:
[TP]pages.page_id = [TP]mod_guestbook.page_ id AND [TP]mod_guestbook.name
  • \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
[TP]pages.page_id = [TP]mod_guestbook.page_ id AND [TP]mod_guestbook.email
  • \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
[TP]pages.page_id = [TP]mod_guestbook.page_ id AND [TP]mod_guestbook.homep age
  • \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
[TP]pages.page_id = [TP]mod_guestbook.page_ id AND [TP]mod_guestbook.messa ge
  • \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'

This code produces correct search results on my site.

Logged
ruebenwurzel
WebsiteBaker Org e.V.

Online Online

Posts: 7663



WWW
« Reply #1 on: December 30, 2007, 09:07:16 AM »

Hello,

never tried to have more then one guestbook on my page, so never recognized this issue. Will test your code and if it works integrate in the next version of the guestbook modul. But please if you post in futue code here in the forum use the code formating. This is easier for us to read and prevents for copy and paste issues. So you mean to change th code as following?

Code:
$query_start_code = "SELECT [TP]pages.page_id, [TP]pages.page_title, [TP]pages.link FROM [TP]mod_guestbook, [TP]pages WHERE ";

Code:
$query_body_code = "
    [TP]pages.page_id = [TP]mod_guestbook.page_id AND [TP]mod_guestbook.name [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
    [TP]pages.page_id = [TP]mod_guestbook.page_id AND [TP]mod_guestbook.email [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
    [TP]pages.page_id = [TP]mod_guestbook.page_id AND [TP]mod_guestbook.homepage [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\' OR
    [TP]pages.page_id = [TP]mod_guestbook.page_id AND [TP]mod_guestbook.message [O] \'[W][STRING][W]\' AND [TP]pages.searching = \'1\'
    ";

Thanks

Matthias
Logged
Achrist

Offline Offline

Posts: 37


« Reply #2 on: December 31, 2007, 12:20:41 PM »

Thats right, thanks.
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!