title: search engine and pagination
body: <p>Hello Friends I want to know how to add pagination in search engine. I have tried so many times to add pagination in search engine but every time i was fail. Is there anybody who modify my following code to add pagination: </p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php include 'func.inc.php'; ?&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;title&gt;Search&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;h2&gt; Search &lt;/h2&gt;
  
  &lt;form action="" method="POST"&gt;
          &lt;p&gt;
              &lt;input type="text" autocomplete="off" name="keywords" /&gt; &lt;input type="submit" value="Search" /&gt;
          &lt;/p&gt;
  &lt;/form&gt;
  &lt;?php
  if (isset($_POST['keywords'])) {
  $suffix = "";
  $keywords = mysql_real_escape_string (htmlentities (trim($_POST['keywords'])));
  
      $errors = array();
  
      if (empty($keywords)) {
          $errors[] = 'Please enter a search term';
      } else if (strlen($keywords)&lt;3) {
          $errors[] = 'Your search term must be three or more character';
      } else if (search_results($keywords) === false) {
          $errors[] = 'Your search for ' .$keywords. ' returned no result';
      }
  
      if (empty($errors)) {
          $results = search_results ($keywords);
          $results_num = count ($results);
  
          $suffix = ($results_num !=1) ? 's' : '';
  
          echo '&lt;p&gt; Your search for &lt;strong&gt;', $keywords,'&lt;/strong&gt; returned &lt;strong&gt;',$results_num,'&lt;/strong&gt; result',$suffix,'&lt;/p&gt;';
          foreach($results as $result) {
              echo '&lt;p&gt;&lt;strong&gt;&lt;a href="',$result['url'],'"&gt;', $result['title'],'&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;', $result['description'],'...&lt;br&gt;', $result['url'],'&lt;/p&gt;';
              }
  
      } else {
      foreach ($errors as $error) {
          echo $error, '&lt;/br&gt;';
      }
          }
  
      }
  
  ?&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>func.inc.php</strong></p>
  
  <pre><code>   &lt;?php 
  include 'db.inc.php'; 
  
  function search_results($keywords) {
      $returned_results = array();
      $where ="";
  
      $keywords = preg_split('/[\s]+/', $keywords);
      $total_keywords = count($keywords);
  
      foreach ($keywords as $key=&gt;$keyword) {
        $where .="`keywords` LIKE '%$keyword%'";
        if ($key != ($total_keywords - 1)) {
          $where .= "AND";
          }
      }
  
      $results = "SELECT `title`, LEFT(`description`, 70) as `description`, `url` FROM `articles` WHERE $where";
      $results_num = ($results = mysql_query($results)) ? mysql_num_rows($results): 0;
  
      if ($results_num === 0) {
      return false;
      } else {
  
      while ($results_row = mysql_fetch_assoc($results)) {
          $returned_results[] = array(
                      'title' =&gt; $results_row['title'],
                      'description' =&gt; $results_row['title'],
                      'url' =&gt; $results_row['url']
  
  
          );
      }
  
      return $returned_results;
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>And i have one more question  to make a close button at the top of the Div for closing itself.</p>