Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:40:25+00:00 2026-06-08T20:40:25+00:00

im trying to implement a search for a project I’m currently working on. problem

  • 0

im trying to implement a search for a project I’m currently working on. problem that im facing is when i go to the 2nd page seach result will be wrong.

here is the search form that is in my header.php

<form name="search" id="search" method="post" action="search.php">
<input type="text" tabindex="1" class="input" id="term" name="term" value=""/>
<input type="submit" tabindex="2" id="submit" value="SEARCH" />

Here is my search page php code

<?php include ('header.php'); 

$term = $_POST['term'];

    $queryn = mysql_query("select * from scripts where title like '%$term%' or discription like '%$term%' and approved='1'") or die (mysql_error());
    $search_num_rows = mysql_num_rows($queryn);
    ?>  
    <div class="cat_script_container">
    <div class="nresults">Found <?php echo $search_num_rows;?> results for "<?php echo $term;?>"</div>
    <?php   
    // How many adjacent pages should be shown on each side?
    $adjacents = 3;

    /* 
       First get total number of rows in data table. 
       If you have a WHERE clause in your query, make sure you mirror it here.
    */
    //$query = "SELECT COUNT(*) as num FROM $tbl_name";
    $query = "select COUNT(*) as num from scripts where title like '%$term%' or discription like '%$term%' and approved='1' order by script_id  desc";
    $total_pages = mysql_fetch_array(mysql_query($query));
    $total_pages = $total_pages['num'];

    /* Setup vars for query. */
    //$targetpage = "category-$cr[cname]-$cid.html";    //your file name  (the name of this file)
    $catn = strtolower($cr['cname']);   //Turn category name in to lowercase
    $catn = preg_replace("![^a-z0-9]+!i", "-", $catn);
    $limit = 2;                                 //how many items to show per page
    $page = $_GET['page'];

    if($page) 
        $start = ($page - 1) * $limit;          //first item to display on this page
    else
        $start = 0;                             //if no page var is given, set start to 0
    /* Get data. */
    $sql = "select * from scripts where title like '%$term%' or discription like '%$term%' and approved='1' order by script_id  desc LIMIT $start, $limit";

    $result = mysql_query($sql);

    /* Setup page vars for display. */
    if ($page == 0) $page = 1;                  //if no page var is given, default to 1.
    $prev = $page - 1;                          //previous page is page - 1
    $next = $page + 1;                          //next page is page + 1
    $lastpage = ceil($total_pages/$limit);      //lastpage is = total pages / items per page, rounded up.
    $lpm1 = $lastpage - 1;                      //last page minus 1

    /* 
        Now we apply our rules and draw the pagination object. 
        We're actually saving the code to a variable in case we want to draw it more than once.
    */
    $pagination = "";
    if($lastpage > 1)
    {   
        $pagination .= "<div class=\"pagination\">";
        //previous button
        if ($page > 1) 
            $pagination.= "<a href=\"search-$prev.html\">« previous</a>";
        else
            $pagination.= "<span class=\"disabled\">« previous</span>"; 

        //pages 
        if ($lastpage < 7 + ($adjacents * 2))   //not enough pages to bother breaking it up
        {   
            for ($counter = 1; $counter <= $lastpage; $counter++)
            {
                if ($counter == $page)
                    $pagination.= "<span class=\"current\">$counter</span>";
                else
                    $pagination.= "<a href=\"search-$counter.html\">$counter</a>";                  
            }
        }
        elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some
        {
            //close to beginning; only hide later pages
            if($page < 1 + ($adjacents * 2))        
            {
                for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        $pagination.= "<a href=\"search-$counter.html\">$counter</a>";                  
                }
                $pagination.= "...";
                $pagination.= "<a href=\"search-$lpm1.html\">$lpm1</a>";
                $pagination.= "<a href=\"search-$lastpage.html\">$lastpage</a>";        
            }
            //in middle; hide some front and some back
            elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
            {
                $pagination.= "<a href=\"search-1.html\">1</a>";
                $pagination.= "<a href=\"search-2.html\">2</a>";
                $pagination.= "...";
                for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        $pagination.= "<a href=\"search-$counter.html\">$counter</a>";                  
                }
                $pagination.= "...";
                $pagination.= "<a href=\"search-$lpm1.html\">$lpm1</a>";
                $pagination.= "<a href=\"search-$lastpage.html\">$lastpage</a>";        
            }
            //close to end; only hide early pages
            else
            {
                $pagination.= "<a href=\"search-1.html\">1</a>";
                $pagination.= "<a href=\"search-2.html\">2</a>";
                $pagination.= "...";
                for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        $pagination.= "<a href=\"search-$counter.html\">$counter</a>";                  
                }
            }
        }

        //next button
        if ($page < $counter - 1) 
            $pagination.= "<a href=\"search-$next.html\">next »</a>";
        else
            $pagination.= "<span class=\"disabled\">next »</span>";
        $pagination.= "</div>\n";       
    }

    $q=mysql_query("select * from scripts where title like '%$term%' or discription like '%$term%' and approved='1' order by script_id  desc limit $start,$limit");
    $numr=mysql_num_rows($q);
    if ($numr==0)
    {
    echo '<div class="msg_info_box">No results were found. Please try a different search.</div>';
    }
    while($script=mysql_fetch_assoc($q)){
    $str = $script['discription'];
    $wcount = strlen($str);
    if ($wcount > 295){
    $dis = substr($str, 0, 295).'...';
    }else{
    $dis = $str;

}
    $sname = $script['title'];
    $sname = preg_replace("![^a-z0-9]+!i", "-", $sname);
    $sname = strtolower($sname);
    $lid = $script['licens_id'];

$license= mysql_query("SELECT * FROM licens WHERE id='$lid' LIMIT 1") or die (mysql_error());
$lrow = mysql_fetch_array($license);

?>
<div class="new_scripts">
<div class="n_title"><a href="script-<?php echo $script['script_id'];?>-<?php echo $sname;?>.html"><?php echo $script['title'];?></a></div>
<div class="n_dis"><?php echo $dis;?></div>
<div class="n_menu">
<!--#--> 
<div class="ii_info"><span class="is_lable"><a class="s_link" href="<?php echo $script['script_url'];?>" target="_blank">Visit Publisher Site</a></span> | </div>
<div class="ii_info"><span class="is_lable"><a class="s_link" href="<?php echo $script['script_demo'];?>" target="_blank">View Demo</a></span></div>
<div class="i_info"><span class="is_lable">License Type:</span><span class="license"> <?php echo $lrow['lname'];?></span></div>
<!--#-->
</div>
</div> 
<?php } ?>

<div class="pagediv"><?php echo $pagination;?></div>
</div>

im wondering is the any way to give the search form action like action=”search.php?term=keyword. i think if i can post the url like this i can use $_GET to take the keyworkd. if anyone can help me with this in anyway i really appropriated. thanks in advanced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:40:28+00:00Added an answer on June 8, 2026 at 8:40 pm

    Change your action attribute to get

    <form name="search" id="search" method="get" action="search.php">
    

    This way your form’s values will be appended to search.php on submission.

    For example:

    search.php?term=the_term
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Problem : I am trying to implement a search algorithm that shows the
I'm currently trying to implement some kind of search system in a program of
I am trying to implement an efficient algorithm for nearest-neighbour search problem. I have
I'm trying to implement popup search window in a PHP project. I included JQuery
I am trying to implement bing search in my site. I need search result
Currently I am working on an MVC 2 project and we are trying to
I'm trying to implement search result highlighting for pdfs in a web app. I
I'm trying to implement Search Engine. I have web application that displays list of
I'm trying to implement a search for my project , but i can't figure
I have been trying to implement a search page for the admin of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.