title: Make the PHP MySql Search Engine and Pagination work
body: <p>I don't know how to make the search through another table. how should i do that?
  the table name is comments and i want to search for all the post stored in the column name kom</p>
  
  <p>Another thing is that i cant get the pagination start working...
  I started the pagination within an else statment because i only need it when i get more than 1 result.
  I can get the page links showing and limit the search posting showing but when i click on one off the links i cant get to the next page
  Heres the code</p>
  
  <pre><code>&lt;?php 
      $search = $_POST["search"];
      $field = $_POST["field"];
  
      if($_POST["submit"] &amp;&amp; $search)
      {   
          echo "&lt;div id='result'&gt;";
          echo "&lt;h2&gt;Resultat&lt;/h2&gt;";
      $search = strtoupper($search);
      $search = strip_tags($search);
      $search = trim($search);
  
      $query = "SELECT * FROM blogTable WHERE title LIKE '%$search%' 
                UNION 
                SELECT * FROM blogTable WHERE post LIKE '%$search%'";
      $result = mysql_query($query, $conn) or die(mysql_error());
  
      $matches = mysql_num_rows($result);
  
      if($matches == 0)
          //code if serch didnt result any results
  
      else if($matches == 1)
              //code if the matches only 1
  
      else
      {
  
          $per_page = 4;
          $pages = ceil($matches / $per_page);
          $page = (isset($_GET['page'])) ? (int)$_GET['page']: 1;
          $start = ($page - 1) * $per_page;
          $query2 = "SELECT * FROM blogTable WHERE title LIKE '%$search%' 
                            UNION 
                            SELECT * FROM blogTable WHERE post LIKE '%$search%' LIMIT $start, $per_page";
          $result2 = mysql_query($query2, $conn) or die(mysql_error());
  
  
          echo "&lt;font size='-1'&gt;Sökningen $search gav $matches resultat&lt;/font&gt;&lt;br/&gt;";
          while ($r2 = mysql_fetch_array($result2))
          {
              $id = $r["id"]; 
              $title = $r["title"]; 
              $post = $r["post"]; 
              $time = $r["time"];
  
              echo "&lt;br/&gt;&lt;strong&gt;&lt;a href='comment.php?id=$id'&gt;$title&lt;/a&gt;&lt;/strong&gt;&lt;br/&gt;";
              echo "&lt;font size='-1'&gt;".substr($post, 0, 60)."&lt;/font&gt;&lt;br/&gt;";
              echo "&lt;font size='-1'&gt;".substr($post, 60, 70)."&lt;/font&gt;&lt;br/&gt;";
              echo "&lt;font size='-3'&gt;$time&lt;/font&gt;&lt;br/&gt;";   
          }
  
              //theese are showin but cannot click of any of them
                  if($pages &gt;= 1 &amp;&amp; $page &lt;= $pages)
              {
                  for($nr = 1; $nr &lt;= $pages; $nr++)
                  {
                      if($nr == $page)
                          echo "&lt;a href='?page=".$nr."' style='font-size:20px;'&gt;$nr&lt;/a&gt;";
                      else
                          echo "&lt;a href='?page=".$nr."' style='font-size:15px;'&gt;$nr&lt;/a&gt; ";
                  }
              } 
          }   
      }
  
      ?&gt;
  </code></pre>