8-4
search.php
require_once 'header.php' ; |
$op = isset( $_REQUEST [ 'op' ]) ? filter_var( $_REQUEST [ 'op' ]) : '' ; |
$keyword = isset( $_REQUEST [ 'keyword' ]) ? filter_var( $_REQUEST [ 'keyword' ]) : '' ; |
search_article( $keyword ); |
require_once 'footer.php' ; |
function search_article( $keyword = '' ) |
$keys = explode ( ' ' , $keyword ); |
header( 'location:index.php' ); |
foreach ( $keys as $value ) { |
$key_array [] = "(`title` LIKE '%{$value}%' OR `content` LIKE '%{$value}%')" ; |
header( 'location:index.php' ); |
$search_str = implode( ' or ' , $key_array ); |
$sql = "SELECT * FROM `article` WHERE $search_str ORDER BY `update_time` DESC " ; |
include_once "PageBar.php" ; |
$PageBar = getPageBar( $db , $sql , 3, 10); |
$total = $PageBar [ 'total' ]; |
$result = $db ->query( $sql ) or die ( $db ->error); |
while ( $data = $result ->fetch_assoc()) { |
$all [ $i ][ 'summary' ] = mb_substr( strip_tags ( $data [ 'content' ]), 0, 90); |
$smarty ->assign( 'all' , $all ); |
$smarty ->assign( 'bar' , $bar ); |
$smarty ->assign( 'total' , $total ); |