source: temp/test-xoops.ec-cube.net/html/modules/mylinks/include/search.inc.php @ 405

Revision 405, 3.2 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: search.inc.php,v 1.2 2005/03/18 12:52:25 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27
28function mylinks_search($queryarray, $andor, $limit, $offset, $userid){
29    global $xoopsDB;
30    $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,t.description FROM ".$xoopsDB->prefix("mylinks_links")." l LEFT JOIN ".$xoopsDB->prefix("mylinks_text")." t ON t.lid=l.lid WHERE status>0";
31    if ( $userid != 0 ) {
32        $sql .= " AND l.submitter=".$userid." ";
33    }
34    // because count() returns 1 even if a supplied variable
35    // is not an array, we must check if $querryarray is really an array
36    if ( is_array($queryarray) && $count = count($queryarray) ) {
37        $sql .= " AND ((l.title LIKE '%$queryarray[0]%' OR t.description LIKE '%$queryarray[0]%')";
38        for($i=1;$i<$count;$i++){
39            $sql .= " $andor ";
40            $sql .= "(l.title LIKE '%$queryarray[$i]%' OR t.description LIKE '%$queryarray[$i]%')";
41        }
42        $sql .= ") ";
43    }
44    $sql .= "ORDER BY l.date DESC";
45    $result = $xoopsDB->query($sql,$limit,$offset);
46    $ret = array();
47    $i = 0;
48    while($myrow = $xoopsDB->fetchArray($result)){
49        $ret[$i]['image'] = "images/home.gif";
50        $ret[$i]['link'] = "singlelink.php?cid=".$myrow['cid']."&amp;lid=".$myrow['lid']."";
51        $ret[$i]['title'] = $myrow['title'];
52        $ret[$i]['time'] = $myrow['date'];
53        $ret[$i]['uid'] = $myrow['submitter'];
54        $i++;
55    }
56    return $ret;
57}
58?>
Note: See TracBrowser for help on using the repository browser.