0

動的選択ボックスから選択した値を取得する方法を知りたいです。選択した値を取得したら、それを別の php ファイルにある別の変数に保存します。この変数は、postgresql の sql クエリで役立ちます。

//最初のphpファイル

 <form name="boton_alta_soniador" action="dar_alta_soniador.php" method="POST" autocomplete="off">          
<div class="text-field">
   Nombre de la asociacion
<? $strconn="dbname=postgres port=5432 host=127.0.0.1 user=xxx password=xxx";
     $conn=pg_Connect($strconn);

  $consulta="Select n_asociacion from asociacion";
      $result=pg_query($conn,$consulta);
      while($results [] =pg_fetch_object($result));
      array_pop($results);?>

      <select name="asociacion_seleccion" id="i_clave_asociacion">
           <?php foreach ( $results as $option ) : ?>
           <option value="<?php echo $option->i_clave_asociacion; ?>"><?php echo $option->n_asociacion; ?></option>
            <?php endforeach; ?>
      </select>          
  </div>
</form>

これは単なる動的選択ボックスです。次に、選択した値をこの変数に保存します。

$ingresaAsociacion       = pg_escape_string($_POST['asociacion_seleccion']);

したがって、次のステートメントをクエリできます。

$conocerIDasociacion     =  "SELECT N_ASOCIACION FROM ASOCIACION WHERE I_CLAVE_ASOCIACION='$ingresaAsociacion'";

システム全体がほぼ完全に PHP と HTML で作成されているため、jQuery は使用しませんでした。どんな助けでも大歓迎です。私はすべての人に耳を傾けています。

乾杯!

4

2 に答える 2