:::

13-5 上課範例:include/search.php

<?php
function tad_note_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 `note_sn` , `note_title` , `note_date` , `uid` FROM ".$xoopsDB->prefix("tad_notes")." WHERE `note_public`='1' ";
	if ( $userid != 0 ) {
		$sql .= " AND uid=".$userid." ";
	}
	if ( is_array($queryarray) && $count = count($queryarray) ) {
		$sql .= " AND ((`note_title` LIKE '%{$queryarray[0]}%' OR `note_content` LIKE '%{$queryarray[0]}%' OR `note_date` LIKE '%{$queryarray[0]}%')";
		for($i=1;$i<$count;$i++){
			$sql .= " $andor ";
			$sql .= "( `note_title` LIKE '%{$queryarray[$i]}%' OR `note_content` LIKE '%{$queryarray[$i]}%' OR `note_date` LIKE '%{$queryarray[$i]}%')";
		}
		$sql .= ") ";
	}
	$sql .= "ORDER BY `note_sort` DESC";
	$result = $xoopsDB->query($sql,$limit,$offset);
	$ret = array();
	$i = 0;
 	while($myrow = $xoopsDB->fetchArray($result)){
		$ret[$i]['image'] = "images/note.png";
		$ret[$i]['link'] = "view.php?note_sn=".$myrow['note_sn'];
		$ret[$i]['title'] = $myrow['note_title'];
		$ret[$i]['time'] = strtotime($myrow['note_date']);
		$ret[$i]['uid'] = $myrow['uid'];
		$i++;
	}
	return $ret;
}
?>

:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.cp22.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D637%26tbsn%3D22

書籍目錄

展開 | 闔起

線上使用者

345人線上 (139人在瀏覽線上書籍)

會員: 0

訪客: 345

更多…