title: PHP dynamic table is duplicating the information from my mysql table
body: <p>Well I'm making an school project and I need to get the students from table 'alumnos' <em>(I'm from Mexico so my table is in spanish)</em> that are in an specific career (table is 'carreras') from example engineering in computer Systems.</p>
  
  <p>Well <strong>I get the results</strong>(I have 2 students) <strong>but it duplicates each one three times and I don't know why</strong></p>
  
  <p>This is the code I'm using: </p>
  
  <pre><code>    &lt;?php
         include_once ("conexion.php");
  
      $Idcar = $_POST["Combo"];
  
      $sql="SELECT Car_ID_pk FROM carreras WHERE Car_nombre = '$Idcar'";
  
      $cs=mysql_query($sql, $cn);
      while($row=mysql_fetch_array($cs))
      {
          $idcarrera=$row["Car_ID_pk"];
      }
  
  $query = "SELECT alumnos.Al_id_pk, alumnos.Al_nombre, alumnos.Al_ap_pat, alumnos.Al_ap_mat FROM alumnos,carreras WHERE alumnos.Carrera_ID= '$idcarrera'"; 
  $cs1 = mysql_query($query,$cn);
  $i = 0;
  
  $dyn_table = '&lt;table border="1" cellpadding="10"&gt;';
  $dyn_table .= '&lt;tr&gt;&lt;td&gt;Numero de control&lt;/td&gt;&lt;td&gt;Nombre&lt;/td&gt;&lt;td&gt;Apellido paterno&lt;/td&gt;&lt;td&gt;Apellido materno&lt;/td&gt;&lt;/tr&gt;';
  while($row = mysql_fetch_array($cs1)){ 
  
      $NumControl = $row["Al_id_pk"];
      $Nombre = $row["Al_nombre"];
      $Paterno = $row["Al_ap_pat"];
      $Materno = $row["Al_ap_mat"];
  
      if ($i % 4 == 0) 
      {
          $dyn_table .= '&lt;tr&gt;&lt;td&gt;' .$NumControl. '&lt;/td&gt;&lt;td&gt;'.$Nombre.'&lt;/td&gt;&lt;td&gt;'.$Paterno.'&lt;/td&gt;&lt;td&gt;'.$Materno.'&lt;/td&gt;';
      } else 
      {
          $dyn_table .= '&lt;tr&gt;&lt;td&gt;' . $NumControl . '&lt;/td&gt;&lt;td&gt;'.$Nombre.'&lt;/td&gt;&lt;td&gt;'.$Paterno.'&lt;/td&gt;&lt;td&gt;'.$Materno.'&lt;/td&gt;&lt;/tr&gt;';
      }
      $i++;
  }
  $dyn_table .= '&lt;/tr&gt;&lt;/table&gt;';
  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h3&gt;Alumnos registrados.&lt;/h3&gt;
  
  &lt;?php echo 
  
  $dyn_table; ?&gt;
  
  &lt;form name="RS" method="POST" action="ABCCarrera.php"&gt;
      &lt;input type="submit" value="Salir" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>like you can see im using an implicit join, there is a way i can fix this and where is my error?</p>