1
krayc
I need help with search funtion for guestbook...
  • 2004/4/19 12:33

  • krayc

  • Not too shy to talk

  • Posts: 107

  • Since: 2004/2/17


I borrowed a search funtion from 'news' I think it was, to myGuestbook searchable. I have two issues with it, beside trying to figure out what to display in the 'link', In general it doesn't seem to find the search word(s). I've turned on the php Debug, and after fixing a php script error message, it seems to work (ie when searching the function is called) yet it never produces results.
(yes I've added it to the xoops_version file)

below is the function:

function mission_search($queryarray, $andor, $limit, $offset, $userid){
global $xoopsDB;
$sql = "SELECT id,name,title,message, time FROM ".$xoopsDB->prefix("myguestbook")."";

if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= " AND ((name LIKE '%$queryarray[0]%' OR title LIKE '%$queryarray[0]%' OR message LIKE '%$queryarray[0]%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "(name LIKE '%$queryarray[$i]%' OR title LIKE '%$queryarray[$i]%' OR message LIKE '%$queryarray[$i]%')";
}
$sql .= ") ";
}
$sql .= "ORDER BY id DESC";
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
// $ret[$i]['image'] = "images/forum.gif";
$ret[$i]['link'] = "index.php?start=0";
$ret[$i]['title'] = $myrow['title'];
$ret[$i]['time'] = $myrow['time'];
$i++;
}
return $ret;
}
?>


thanks for help in advance, krayc

2
Herko
Re: I need help with search funtion for guestbook...
  • 2004/4/19 12:44

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


hhttp://wiki.xoops.org/wakka.php?wakka=XoopsModuleSearch

That's all I can do to help, I'm afraid....

Herko

3
krayc
Re: I STILL need help with search funtion for guestbook...
  • 2004/4/19 12:51

  • krayc

  • Not too shy to talk

  • Posts: 107

  • Since: 2004/2/17


I checked the wiki, it's empty when I go there?

krayc

4
Herko
Re: I need help with search funtion for guestbook...
  • 2004/4/19 12:54

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


some help I am heh? Sorry, I thought it was there...

Herko

5
krayc
Re: I need help with search funtion for guestbook...
  • 2004/4/19 18:40

  • krayc

  • Not too shy to talk

  • Posts: 107

  • Since: 2004/2/17


Surely this is not to difficult??

This is the same code used in newbb.

I replaced the sql table name, and fields etc.
and the ret info at the bottom, otherwise it is the same
code.

At least could someone tell me how to debug such code, for example how to I get some output to the screen while the code is running?

So i can see if and where it is being excuted?

thanks krayc

6
krayc
Re: Found problem but I need help with search funtion for guestbook...
  • 2004/4/19 19:55

  • krayc

  • Not too shy to talk

  • Posts: 107

  • Since: 2004/2/17


Making progress, but still can't figure whats wrong...

Here is the offending sql statement.

SELECT id,name,title,message, time FROM xoops_myguestbook AND ((name LIKE '%searchword%' OR title LIKE '%searchword%' OR message LIKE '%searchword%')) ORDER BY id DESC LIMIT 0, 5


I'm sure it's staring me in the face.

krayc

7
krayc
Re: Found problem but I need help with search funtion for guestbook...
  • 2004/4/19 20:59

  • krayc

  • Not too shy to talk

  • Posts: 107

  • Since: 2004/2/17


Solved.

Quote:
the AND should be a WHERE


krayc

Login

Who's Online

916 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 916


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits