0
I’m trying to make a query but return me the values selected in a select and I can’t because it returns all the entered values. Can someone please help me?
<form id="form1" name="form1" method="post" action="consultar_documento.php">
Selecionar Tipo de Documento
<select name="COMBO" id="COMBO">
<option></option>
<?php    
$botao   = $_REQUEST['BT'];
$server  = 'localhost';
$DBName  = 'arquivo';
$senha   = '';
$usuario = 'root';
$con12=mysql_connect($server,$usuario,$senha);
if($con12) {
  $selecionar=mysql_select_db($DBName,$con12);
  if($selecionar) {
    $consulta="SELECT descricao FROM tipo_de_documento";
    $resultado=mysql_query($consulta,$con12);
    while ($Reg=mysql_fetch_row($resultado)) {
      foreach ($Reg as $Val) {
        echo "<option>$Val</option>";
      }
    }
    mysql_close($con12);
  }
}
?>  
</select> 
<input type="submit" name="BT" id="BT" value="Consultar" />
</form> 
<?php 
$botao=$_REQUEST['BT'];
$server='localhost';
$DBName='arquivo';
$senha='';
$usuario='root';
$con12 = mysql_connect($server,$usuario,$senha);   
if($con12) {
  $selecionar=mysql_select_db($DBName,$con12);
  if($selecionar) {
    if($botao=='Consultar') {
      if ((isset($_POST['interno'])) && (!empty($_POST['externo']))) {
        $consulta = "SELECT tipo_de_documento.id_tipodocumento, tipo_de_documento.descricao, 
        tipo_de_documento.Data_entrada, tipo_de_documento.Data_saida, tipo_de_documento.UEO, 
        documento.assunto, documento.n_doc, documento.n_folhas, documento.n_exemplares, 
        documento.iddocumento, tipo_de_documento.id_tipodocumento 
        FROM documento, tipo_de_documento 
        WHERE tipo_de_documento.descricao = '".$_POST['tipo_de_documento']."'";
      }
      $resultado=mysql_query($consulta,$con12);
      echo "<table border='1' align='center' width='900' bgcolor='#FFFFFF'> ";
      echo "<tr>"; 
      echo "<table border='1' align='center' width='900' bgcolor='#FFFFFF'> ";  
      echo "<tr>"; 
      echo "<th colspan='9'>";
      echo 'documento';echo $COMBO;
      echo "</th>"; 
      echo "</tr>";
      echo "<tr>";
      echo "<th>";
      echo 'IDENTIFICADOR DE DOCUMENTO';
      echo "</th>";
      echo "<th>";
      echo 'DESCRICAO';
      echo "</th>";
      echo "<th>";
      echo 'DATA_ENTRADA';
      echo "</th>";
      echo "<th>";
      echo 'DATA_SAIDA';
      echo "</th>";
      echo "<th>";
      echo 'UEO';
      echo "</th>";
      echo "<th>";
      echo 'ASSUNTO';
      echo "</th>";
      echo "<th>";
      echo 'NUMERO DO DOCUMENTO';
      echo "</th>"; 
      echo "<th>";
      echo 'NUMERO DE FOLHAS';
      echo "</th>";
      echo "<th>";
      echo 'NUMERO DE EXEMPLARES';
      echo "</th>";
      echo "<th>";
      echo mysql_num_rows($resultado) or die ("".mysql_error ());
      while ($Reg=mysql_fetch_row($resultado)) {
        echo "<tr>";
        foreach ($Reg as $Val) {
          echo "<td>$Val</td> ";
        }
        echo "</tr>";
      }
      echo "</table>";
      mysql_close($con12);
    }
  }
}
?>
</td>
</tr>
</table>
						
Shouldn’t have a
wheresomewhere?– Woss
Look at this subject
– Marco Souza
What method do you use in
<form>and what thenameof<select>?– Wendel Rodrigues
in the form use the post method
– Epifania