title: Submit form on same page and echo records from database
body: <p>I'm trying to submit the form and echo the data from the MySQL table on the same page, but it doesn't show anything, I think I have something wrong in my code, but I don't know what it is.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  if ( isset($_POST['consulta']) )
  {
      echo"
              &lt;table align='center' border='1' class='TablaConsulta'&gt;
                  &lt;tr&gt;;
                      &lt;td&gt;Codigo Escaneado&lt;/td&gt;
                      &lt;td&gt;Nombre Producto&lt;/td&gt;
                      &lt;td&gt;Precio Prodcuto&lt;/td&gt;
                  &lt;/tr&gt;
      ";
          include ("connector.php");
          $con = conectar();
          $tbl = "productos";
          $query = "SELECT * FROM $tbl WHERE  CodigoProducto =".$_POST['CoProducto'];
          $resultado = mysql_query($query, $con) or die(mysql_error($con));   
          while($dato=mysql_fetch_array($resultado)){
                  echo "&lt;tr&gt;";
                  echo "&lt;td&gt;".$dato['CodigoProducto']."&lt;/td&gt;";
                  echo "&lt;td&gt;".$dato['Descripcion']."&lt;/td&gt;";
                  echo "&lt;td&gt;".$dato['Precio']."&lt;/td&gt;";
                  echo "&lt;/tr&gt;";
          }
  
          mysql_close($con);//cerrar conexion
      echo"&lt;/table&gt;";
  
  }
  ?&gt;
  </code></pre>