title: (PHP) Get repeated data (MySQL) from a value in a dropdown list and show it in a table
body: <p>I have a file that has a dropdown list with a set of values (matricula) from a database (movimentos) what I want is when I select that value in the dropdown list it searches the database for repeated rows and it shows it in a table with all the data from that value (it's currently 3 columns, "matricula,"marca" and "despesa")</p>
  
  <p>Below is the code I use to get the value from the dropdown list, and this is where I have the problem, I can't get the value from the dropdown list to show the respective rows in the table.</p>
  
  <pre><code> &lt;a href='verificar.dwt.php'&gt;Voltar atrás&lt;/a&gt;
  
  &lt;div align="center"&gt;&lt;? 
  
  include 'configmov.dwt.php'; 
  
  $tableName='movimentos';
  $matricula = mysql_real_escape_string($_POST['matricula']);
  
  $sql="SELECT matricula, marca, despesa FROM $tableName WHERE $matricula in (SELECT matricula FROM $tableName GROUP BY $matricula HAVING count($matricula) &gt; 1)"; 
  $result=mysql_query($sql); 
  $n=1; 
  
  echo "Os seus resultados: &lt;p&gt;";
  
  echo "&lt;table border=0&gt;";
  echo "&lt;tr bgcolor='#CCFFCC'&gt;";
  echo "&lt;td style='width: 100px;'&gt;Matricula&lt;/td&gt;";
  echo "&lt;td style='width: 100px;'&gt;Marca&lt;/td&gt;";
  echo "&lt;td style='width: 100px;'&gt;Despesa&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result)){ 
      echo "&lt;table border=0&gt;";
      echo "&lt;tr bgcolor='#CCCCCC'&gt;";
      echo "&lt;td style='width: 100px;'&gt;".$row['matricula']."&lt;/td&gt;";
      echo "&lt;td style='width: 100px;'&gt;".$row['marca']."&lt;/td&gt;";
      echo "&lt;td style='width: 100px;'&gt;".$row['despesa']."&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  
  }
  
  ?&gt;
  
  &lt;/div&gt;
  
  &lt;?php
  // close connection; 
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>I'm around this problem for a while and I did a lot of research before coming here to make this question.</p>