php - How do I retrieve a selected value from a dynamically selection box -


i know how retrieve selected value dynamically selection box. if selected value store variable located in php file. variable me in sql query in postgresql.

//first php file

 <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 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 $option ) : ?>            <option value="<?php echo $option->i_clave_asociacion; ?>"><?php echo $option->n_asociacion; ?></option>             <?php endforeach; ?>       </select>             </div> </form> 

this dynamically selection box. want store selected value in variable:

$ingresaasociacion       = pg_escape_string($_post['asociacion_seleccion']); 

so can query following statement:

$conoceridasociacion     =  "select n_asociacion asociacion i_clave_asociacion='$ingresaasociacion'"; 

i didn't want use jquery because whole system entirely made in php , html. please, welcome , i'm ears everyone.

cheers!

looks you're missing submit button.

you not have use ajax @ all, nor jquery. can submit form , process selection value see fit.

the selected value in select tag sent dar_alta_soniador.php, , file process data, using exact code wrote:

$_post['asociacion_seleccion'] 

so, in dar_alta_soniador.php write code:

$ingresaasociacion       = pg_escape_string($_post['asociacion_seleccion']); 

and perform query. not have worry sending data around in session variable, post already.

so should ok in code, or may have misunderstood question. have error message or inappropriate behavior?

maybe submit button missing? use code this:

for select tag:

<div class="controls">                                     <select name="list_name">                                         <option>list</option>                                         <?php                                              foreach ($nucleos $inner_array) {                                                 $out = "<option>" . $inner_array['name'] . "</option>";                                                  echo $out;                                             }                                         ?>                                      </select>                                 </div> 

and submit button:

<div class="control-group">                                 <div class="controls">                                                                      <button type="submit" class="btn">confirm</button>                                     <br/>                                                                  </div>                             </div>  </form> 

i using bootstrap here style, html , css. nothing more.

best wishes,


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -