Execute Query according to RadioButton selected

0

I have the following form:

<?php  
  echo"<fieldset>";
    echo"<legend>OPÇÕES</legend>";
  $query_menu = mysql_query("SELECT 
  rm_id     AS FUNCAO,
  rm_desc   AS DESCRICAO,
  rm_obs    AS OBSERVACAO,
  rm_status AS STATUS 
       FROM radios_menu 
            WHERE rm_status='0'");
    while ($row = mysql_fetch_array($query_menu)) {
    $v_funcao    = $row["FUNCAO"];
    $v_desc      = $row["DESCRICAO"];
    $v_obs       = $row["OBSERVACAO"];
    $v_status    = $row["STATUS"];
    echo"<div class='form-group'>";
      echo"<label class='col-lg-2 control-label'></label>";
      echo"<div class='col-lg-10'>";
        echo"<div class='radio'>";
          echo"<label>";
            echo"<input type='radio' name='v_desc' id='$v_funcao' value='$v_funcao' >$v_desc</label></br>";
        echo"</div>";
      echo"</div>";
    echo"</div>";
           }
    echo"<div class='form-group'>";
      echo"<div class='col-lg-10 col-lg-offset-2'>";
        echo"<button type='submit' class='btn btn-primary'>CONSULTAR</button>";
      echo"</div>";
    echo"</div>";

  echo"</fieldset>";
 echo"</form>";
?>

He's posting something like:

 v_desc=1   
 v_desc=2  
 v_desc=3

According to every $_POST I want to execute a different query, how could I do this?

Example:

 v_desc=1 executar Query_01
 v_desc=2 executar Query_02
 v_desc=3 executar Query_03
    
asked by anonymous 22.06.2016 / 16:32

1 answer

1

Adapt this code after your $ _POST

if ($v_desc == 1) {
    // executar Query_01
} else if ($v_desc == 2) {
    // executar Query_02
} else if ($v_desc == 3) {
    // executar Query_03
}
    
22.06.2016 / 19:46