46 users online (0 members and 46 guests)  


  Results 1 to 2 of 2

Related

  1. form data displayed on html page    Forum: PHP Forum
    Replies: 1
  2. PHP displaying search results    Forum: PHP Forum
    Replies: 24
  3. google search results    Forum: HTML Forum
    Replies: 1
  1. #1
    ejmoska's Avatar
    New User

    Status
    Offline
    Join Date
    May 2014
    Posts
    3

    Question search results to be displayed in new page

    Hello,
    I have recently implemented a search into my website, but the search results are being displayed in the same page as the search window, can you guys help me figure out how to make them appear in a new page, for example in search_results.html page. Here is the code that i have now:


    PHP Code:
    //error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); 
    error_reporting(E_ALL); 
    $include_dir "./include"
    include (
    "$include_dir/commonfuncs.php");
    //extract(getHttpVars());

    if (isset($_GET['query']))
        
    $query $_GET['query'];
    if (isset(
    $_GET['search']))
        
    $search $_GET['search'];
    if (isset(
    $_GET['domain'])) 
        
    $domain $_GET['domain'];
    if (isset(
    $_GET['type'])) 
        
    $type $_GET['type'];
    if (isset(
    $_GET['catid'])) 
        
    $catid $_GET['catid'];
    if (isset(
    $_GET['category'])) 
        
    $category $_GET['category'];
    if (isset(
    $_GET['results'])) 
        
    $results $_GET['results'];
    if (isset(
    $_GET['start'])) 
        
    $start $_GET['start'];
    if (isset(
    $_GET['adv'])) 
        
    $adv $_GET['adv'];
        
        
    $include_dir "./include"
    $template_dir "./templates"
    $settings_dir "./settings"
    $language_dir "./languages";


    require_once(
    "$settings_dir/database.php");
    require_once(
    "$language_dir/en-language.php");
    require_once(
    "$include_dir/searchfuncs.php");
    require_once(
    "$include_dir/categoryfuncs.php");


    include 
    "$settings_dir/conf.php";
    include 
    "$language_dir/$language-language.php";


    if (
    $type != "or" && $type != "and" && $type != "phrase") { 
        
    $type "and";
    }

    if (
    preg_match("/[^a-z0-9-.]+/"$domain)) {
        
    $domain="";
    }


    if (
    $results != "") {
        
    $results_per_page $results;
    }

    if (
    get_magic_quotes_gpc()==1) {
        
    $query stripslashes($query);


    if (!
    is_numeric($catid)) {
        
    $catid "";
    }

    if (!
    is_numeric($category)) {
        
    $category "";




    if (
    $catid && is_numeric($catid)) {

        
    $tpl_['category'] = sql_fetch_all('SELECT category FROM '.$mysql_table_prefix.'categories WHERE category_id='.(int)$_REQUEST['catid']);
    }
        
    $count_level0 sql_fetch_all('SELECT count(*) FROM '.$mysql_table_prefix.'categories WHERE parent_num=0');
    $has_categories 0;

    if (
    $count_level0) {
        
    $has_categories $count_level0[0][0];
    }



    require_once(
    "$template_dir/$template/search_form.html");


    function 
    getmicrotime(){
        list(
    $usec$sec) = explode(" ",microtime());
        return ((float)
    $usec + (float)$sec);
        }




    function 
    saveToLog ($query$elapsed$results) {
            global 
    $mysql_table_prefix;
        if (
    $results =="") {
            
    $results 0;
        }
        
    $query =  "insert into ".$mysql_table_prefix."query_log (query, time, elapsed, results) values ('$query', now(), '$elapsed', '$results')";
        
    mysql_query($query);
                        
        echo 
    mysql_error();
                            
    }

    switch (
    $search) {
        case 
    1:

            if (!isset(
    $results)) {
                
    $results "";
            }
            
    $search_results get_search_results($query$start$category$type$results$domain);
            require(
    "$template_dir/$template/search_results.html");
        break;
        default:
            if (
    $show_categories) {
                if (
    $_REQUEST['catid']  && is_numeric($catid)) {
                    
    $cat_info get_category_info($catid);
                } else {
                    
    $cat_info get_categories_view();
                }
                require(
    "$template_dir/$template/categories.html");
            }
        break;
        }

    ?> 
    this is the search.php page in my website , really need to make the results in a new page any help very much appreciated because im stuck, thanks alot

  2. #2
    ejmoska's Avatar
    New User

    Status
    Offline
    Join Date
    May 2014
    Posts
    3

    Re: search results to be displayed in new page

    So after countless hours of searching i came up with something so i thought i would share it with you guys. Instead of editing search.php i decided to make a new page before that, and used script for query
    PHP Code:
    <form name="myform" action="search.php">
    Search: <input type='text' name='query' />
    <
    a href="javascript: submitform()">Search</a>
    </
    form>
    <
    script type="text/javascript">
    function 
    submitform()
    {
      
    document.myform.submit();
    }
    </script> 
    Now it goes from one page to other and enters information to the search field, just need to submit it somehow (i am a complete noob in php, and yes finding that little script took me almost 2 days)