title: How to display search results in one table with PHP & MySQL?
body: <p>I have the code to do the search. But the search results are not in the same table. All search results appear in a different table. How do I make them appear in one table?</p>
  
  <blockquote>
    <p><strong>Screenshot :</strong></p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/c7wIO.jpg" alt="Screenshot of my application"></p>
  
  <p>And here's my code :</p>
  
  <pre><code>&gt; search.php
  
  &lt;?php
  
      $query = $_GET['query'];
  
  
      $min_length = 1;
  
  
      if(strlen($query) &gt;= $min_length){ 
  
          $query = htmlspecialchars($query);
  
          $query = mysql_real_escape_string($query);
  
          $raw_results = mysql_query("SELECT * FROM barang WHERE (`tanggal` LIKE '%".$query."%')") or die(mysql_error());
  
  
          if(mysql_num_rows($raw_results) &gt; 0){ 
  
              while($results = mysql_fetch_assoc($raw_results)){
                  ?&gt;
  
                  &lt;table width="107%" class="view"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
          &lt;th width="180"&gt;Tanggal&lt;/th&gt;
          &lt;th width="150"&gt;Barang Masuk&lt;/th&gt;
          &lt;th width="90"&gt;Bijih Keluar&lt;/th&gt;
          &lt;th width="120"&gt;Kantong Hitam Keluar&lt;/th&gt;
          &lt;th width="120"&gt;Kantong Putih Keluar&lt;/th&gt;
          &lt;th width="90"&gt;Stok Bijih&lt;/th&gt;
          &lt;th width="90"&gt;Stok Kantong Hitam&lt;/th&gt;
          &lt;th width="90"&gt;Stok Kantong Putih&lt;/th&gt;
          &lt;th width="130"&gt;Catatan&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
  
  
  
                      &lt;td&gt;&lt;?php echo $results['tanggal']; ?&gt;&lt;/td&gt;
  
  
  
                  &lt;td&gt;&lt;?php echo $results['barang_in']; ?&gt;&lt;/td&gt;
  
  
                          &lt;td&gt;&lt;?php echo $results['bijih_out']; ?&gt;&lt;/td&gt;
  
  
                  &lt;td&gt;&lt;?php echo $results['htm_out']; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;?php echo $results['pth_out']; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;?php echo $results['bijih']; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;?php echo $results['kantong_htm']; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;?php echo $results['kantong_pth']; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;?php echo $results['note']; ?&gt;&lt;/td&gt;
     &lt;?php             
              }
  
          }
          else{ // if there is no matching rows do following
              echo "Hasil tidak bisa ditemukan atau tidak ada di dalam database.";
          }
  
      }
      else{ 
          echo "Minimum length is ".$min_length;
      }
  ?&gt;
  </code></pre>
  
  <p>So how to make the search results appear just in one table? Am I wrong to put the table code? Or something else? And one more question, How to add numbers for each result? Thank you in advance for your time and the help.</p>