title: Hide php table unless it is called through search
body: <p>I currently have a page where it displays data from my database in tables and it also searchable using some key terms. What I want to do is for the table to be hidden unless it is being searched. I have rephrased my codes because this is an assignment and i dont want it to be picked up as plagiarism. I really hope someone knows a way to do this</p>
  
  <pre><code>&lt;?php
    include_once('connection.php');
  
    $SQL = "SELECT * FROM `players`";
  
    if (isset($_POST['search'])) {
      $search_word = mysql_real_escape_string($_POST['search_bar']);
      $SQL .= " WHERE player_id LIKE '%{$search_word}%'";
      $SQL .= " or player_name LIKE '%{$search_word}%'";
    }
  
    $SQL .= 'group by player_id, player_name order by player_id ASC';
  
    if( !( $SQLRes = mysql_query( $SQL ) ) ){
      echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
    }else{
      if( mysql_num_rows( $SQLRes )==0 ){
        echo '&lt;tr&gt;&lt;td colspan="1"&gt;No results &lt;/td&gt;&lt;/tr&gt;';
      }else{
        $current_player_id = false;
        while( $row = mysql_fetch_assoc( $SQLRes ) ){
          if ($row['player_id'] !=$current_player_id) {
            if ($current_player_id !== false)
               echo '&lt;/table&gt;';
            echo '
                  &lt;h4&gt;'.$row['player_id'].'&lt;/h4&gt;
  
                  &lt;table style = "width: 100%" class="listing" cellpadding="0" cellspacing="0"&gt;
                    &lt;tr&gt;
                      &lt;th style="width: 50%"&gt;Player Name&lt;/th&gt;
                    &lt;/tr&gt;';
  
            $current_player_id = $row['player_id'];
          }
          echo '&lt;tr&gt;
                  &lt;td&gt;'.$row['player_name'].'&lt;/td&gt;
                  &lt;td&gt;&lt;a href =delete.php?del='.$row['player_id'].'&gt;&lt;strong&gt;DELETE&lt;strong/&gt;&lt;/a&gt;&lt;/td&gt;
               &lt;/tr&gt; ';
        }
      }
      echo '&lt;/table&gt;';
  
  ?&gt;
  &lt;/table&gt;
  </code></pre>