Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I retrieve a selected value from a dynamically selection box
    primarykey
    data
    text
    <p>I would like to know how to retrieve a selected value from a dynamically selection box. If I get the selected value then I will store it into another variable that is located in another php file. This variable will help me in a sql query in postgresql.</p> <p>//First php file</p> <pre><code> &lt;form name="boton_alta_soniador" action="dar_alta_soniador.php" method="POST" autocomplete="off"&gt; &lt;div class="text-field"&gt; Nombre de la asociacion &lt;? $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);?&gt; &lt;select name="asociacion_seleccion" id="i_clave_asociacion"&gt; &lt;?php foreach ( $results as $option ) : ?&gt; &lt;option value="&lt;?php echo $option-&gt;i_clave_asociacion; ?&gt;"&gt;&lt;?php echo $option-&gt;n_asociacion; ?&gt;&lt;/option&gt; &lt;?php endforeach; ?&gt; &lt;/select&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>This is just the dynamically selection box. Then I want to store the selected value in this variable: </p> <pre><code>$ingresaAsociacion = pg_escape_string($_POST['asociacion_seleccion']); </code></pre> <p>So I can query the following statement:</p> <pre><code>$conocerIDasociacion = "SELECT N_ASOCIACION FROM ASOCIACION WHERE I_CLAVE_ASOCIACION='$ingresaAsociacion'"; </code></pre> <p>I didn't want to use jQuery because the whole system is almost entirely made in PHP and HTML. Please, any help is welcome and I'm all ears to everyone. </p> <p>Cheers!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload