:::

7-3 /include/search.php

<?php

//搜尋程式

function tad_ebook_search($queryarray, $andor, $limit, $offset, $userid){
  global $xoopsDB;
  if(get_magic_quotes_gpc()){
    foreach($queryarray as $k=>$v){
      $arr[$k]=addslashes($v);
    }
    $queryarray=$arr;
  }
  $sql = "SELECT `page_sn`,`page_title`,`page_post_time`, `uid` FROM ".$xoopsDB->prefix("tad_ebook_page")." WHERE 1";
  if ( $userid != 0 ) {
    $sql .= " AND uid=".$userid." ";
  }
  if ( is_array($queryarray) && $count = count($queryarray) ) {
    $sql .= " AND ((`page_title` LIKE '%{$queryarray[0]}%'  OR `page_content` LIKE '%{$queryarray[0]}%' OR `page_author` LIKE '%{$queryarray[0]}%'  OR `page_tag` LIKE '%{$queryarray[0]}%')";
    for($i=1;$i<$count;$i++){
      $sql .= " $andor ";
      $sql .= "(`page_title` LIKE '%{$queryarray[$i]}%' OR  `page_content` LIKE '%{$queryarray[$i]}%' OR `page_author` LIKE '%{$queryarray[$i]}%'  OR `page_tag` LIKE '%{$queryarray[$i]}%')";
    }
    $sql .= ") ";
  }
  $sql .= "ORDER BY  `page_post_time` DESC";
  $result = $xoopsDB->query($sql,$limit,$offset);
  $ret = array();
  $i = 0;
  while($myrow = $xoopsDB->fetchArray($result)){
    $ret[$i]['image'] = "images/search.png";
    $ret[$i]['link'] = "index.php?page_sn=".$myrow['page_sn'];
    $ret[$i]['title'] = $myrow['page_title'];
    $ret[$i]['time'] = strtotime($myrow['page_post_time']);
    $ret[$i]['uid'] = $myrow['uid'];
    $i++;
  }
  return $ret;
}

?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D37%26tbdsn%3D1159

書籍目錄

展開 | 闔起

線上使用者

37人線上 (7人在瀏覽線上書籍)

會員: 0

訪客: 37

更多…