title: Can´t get value of sum from a selected repeated id (PHP) and (MySQL)
body: <p>I´m trying to get a sum from the column of the repeated values that was selected in a form before, but i can´t even show the result, is there something wrong with this code?</p>
  
  <p>DB Structure</p>
  
  <p>table carros<br>
  -id<br>
  -matricula<br>
  -marca                        </p>
  
  <p>table movimentos<br>
  -id
  -matricula
  -marca
  -fornecedor
  -tipo
  -despesa
  -observacoes</p>
  
  <p>i have a form in the file "verificar.dwt.php" that contains a dropdown list with all the values in "matricula" (from the table carros) and when it selects the respective "matricula" it goes to "extra1.dwt.php" where it shows a table with all the repeated rows that have the same "matricula" value. </p>
  
  <p>What i want to show now is the sum of that repeated rows. </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 = '".$matricula."'";
  $result=mysql_query($sql); 
  
  $result1 = mysql_query('SELECT SUM(value) AS value_sum FROM despesa'); 
  $row1 = mysql_fetch_assoc($result1); 
  $sum = $row1['value_sum'];
  
  $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;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;";
  
      echo $sum;
  }
  </code></pre>