去看 PHPBB 的搜索代码 search.php

解决方案 »

  1.   

    注意参数的传递
        <td height=35 colspan=2 nowrap class=cont> &nbsp;您输入的关键词:<font color=red>php
    </font> 搜索结果:<a href=http://general.search.sohu.com/sortsearch.jsp?key_word=php>类目</a> 
      

  2.   

    谁那里有现成的代码啊?PHPBB 的搜索代码 search.php找太难了!我不是高手啊!!55
      

  3.   

    <?php
    /***************************************************************************
     *                                search.php
     *                            -------------------
     *   begin                : Saturday, Feb 13, 2001
     *   copyright            : (C) 2001 The phpBB Group
     *   email                : [email protected]
     *
     *   $Id: search.php,v 1.72.2.4 2002/05/13 01:30:59 psotfx Exp $
     *
     *
     ***************************************************************************//***************************************************************************
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
     *
     ***************************************************************************/define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);
    include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
    include($phpbb_root_path . 'includes/functions_search.'.$phpEx);//
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_SEARCH);
    init_userprefs($userdata);
    //
    // End session management
    ////
    // Define initial vars
    //
    if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
    {
    $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
    }
    else
    {
    $mode = '';
    }if ( isset($HTTP_POST_VARS['search_keywords']) || isset($HTTP_GET_VARS['search_keywords']) )
    {
    $search_keywords = ( isset($HTTP_POST_VARS['search_keywords']) ) ? $HTTP_POST_VARS['search_keywords'] : $HTTP_GET_VARS['search_keywords'];
    }
    else
    {
    $search_keywords = '';
    }if ( isset($HTTP_POST_VARS['search_author']) || isset($HTTP_GET_VARS['search_author']))
    {
    $search_author = ( isset($HTTP_POST_VARS['search_author']) ) ? $HTTP_POST_VARS['search_author'] : $HTTP_GET_VARS['search_author'];
    }
    else
    {
    $search_author = '';
    }
      

  4.   

    $search_id = ( isset($HTTP_GET_VARS['search_id']) ) ? $HTTP_GET_VARS['search_id'] : '';$show_results = ( isset($HTTP_POST_VARS['show_results']) ) ? $HTTP_POST_VARS['show_results'] : 'posts';if ( isset($HTTP_POST_VARS['search_terms']) )
    {
    $search_terms = ( $HTTP_POST_VARS['search_terms'] == 'all' ) ? 1 : 0;
    }
    else
    {
    $search_terms = 0;
    }if ( isset($HTTP_POST_VARS['search_fields']) )
    {
    $search_fields = ( $HTTP_POST_VARS['search_fields'] == 'all' ) ? 1 : 0;
    }
    else
    {
    $search_fields = 0;
    }$return_chars = ( isset($HTTP_POST_VARS['return_chars']) ) ? intval($HTTP_POST_VARS['return_chars']) : 200;$search_cat = ( isset($HTTP_POST_VARS['search_cat']) ) ? intval($HTTP_POST_VARS['search_cat']) : -1;
    $search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1;$sort_by = ( isset($HTTP_POST_VARS['sort_by']) ) ? intval($HTTP_POST_VARS['sort_by']) : 0;if ( isset($HTTP_POST_VARS['sort_dir']) )
    {
    $sort_dir = ( $HTTP_POST_VARS['sort_dir'] == 'DESC' ) ? 'DESC' : 'ASC';
    }
    else
    {
    $sort_dir =  'DESC';
    }if ( !empty($HTTP_POST_VARS['search_time']) || !empty($HTTP_GET_VARS['search_time']))
    {
    $search_time = time() - ( ( ( !empty($HTTP_POST_VARS['search_time']) ) ? intval($HTTP_POST_VARS['search_time']) : intval($HTTP_GET_VARS['search_time']) ) * 86400 );
    }
    else
    {
    $search_time = 0;
    }
      

  5.   

    哦!错了!我是说在那里提取那段代码太难了!我是不知道哪个是分页代码!search.php
    的代码我已经有了!
      

  6.   

    如何实现象sohu的搜索引擎的分页方式。
    http://site.search.sohu.com/website.jsp?key_word=1&begin=270&numpage1=30
    越详细越好!在一次顶!