Catch Variable Combobox PHP

Asked

Viewed 242 times

0

Good afternoon, Folks

I’m new to the subject, and I’m having trouble capturing the field selected by the user in a combobox to make a change to the database from the selection.

The code of the page.php.

$dbconn = mysqli_connect('localhost','local','x','dblocal');
$query = "SELECT AcoesReinc from DescAcoes";

while ($registro = mysqli_fetch_assoc($consultaslot))
{
echo "<tr>";
    echo "<td>".$registro['TQA_DATA_CRIACAO']."</td>";
echo "<td>".$registro['TQA_CODIGO']."</td>";
echo "<td>".$registro['TQA_RAIZ']."</td>";
echo "<td>".$registro['TAB_FABRICANTE']."</td>";
echo "<td>".$registro['TAB_HOSTNAME']."</td>";
echo "<td>".$registro['TAB_SLOT']."</td>";
echo "<td>".$registro['TAB_PORTA']."</td>";
echo "<td>".$registro['TAX_BAIXA_CAUSA_NOME']."</td>";
echo "<td>".$registro['VERIFICADO']."</td>"; ------> //aqui eu termino de montar o td do primeiro select e inicio o combobox para seleção do campo a partir de um segundo select 

echo "<td><select name='combo' form name ='combo' form action='consultareincidenteteste5.php' method='post'>";
            foreach ($dbconn->query($query) as $prod) {
echo '<option value="'.$prod['AcoesReinc'].'">'.$prod['AcoesReinc'].'</option>';
            }
    '</select>';
    echo "<input type='submit' name='enviar' value='enviar'>";'</form>';
    "<td>";


}}

I’m trying to send what was selected for the relapse consult5.php

 var_dump($_POST);
 $valor = $_POST['combo'];
 echo $valor;

But she returns to me:

 array(0) { }

I wonder how I can store the field that was selected in the combobox by the user.

Thank you very much for your attention!

  • Are you putting the form inside the select? Create a form outside the select

  • You want to send only combo box data?

  • The form was really wrong!! Thank you very much!

1 answer

1


See if this solves:

<?php 

$dbconn = mysqli_connect('localhost','local','x','dblocal');
$query = "SELECT AcoesReinc from DescAcoes";

while ($registro = mysqli_fetch_assoc($consultaslot))
{
    echo "<tr>";
    echo "<td>".$registro['TQA_DATA_CRIACAO']."</td>";
    echo "<td>".$registro['TQA_CODIGO']."</td>";
    echo "<td>".$registro['TQA_RAIZ']."</td>";
    echo "<td>".$registro['TAB_FABRICANTE']."</td>";
    echo "<td>".$registro['TAB_HOSTNAME']."</td>";
    echo "<td>".$registro['TAB_SLOT']."</td>";
    echo "<td>".$registro['TAB_PORTA']."</td>";
    echo "<td>".$registro['TAX_BAIXA_CAUSA_NOME']."</td>";
    echo "<td>".$registro['VERIFICADO']."</td>"; //------> //aqui eu termino de montar o td do primeiro select e inicio o combobox para seleção do campo a partir de um segundo select 
    echo "<form action='consultareincidenteteste5.php' method='post'>";
    echo "<td><select name='combo'>";
        foreach ($dbconn->query($query) as $prod) {
            echo '<option value="'.$prod['AcoesReinc'].'">'.$prod['AcoesReinc'].'</option>';
        }
    echo '</select>';
    echo "<input type='submit' name='enviar' value='enviar'>";
    echo '</form>';
    echo "</td>";
    echo "<tr>";
}
  • It worked man!! Thank you so much!! I was all day in this hehehe

Browser other questions tagged

You are not signed in. Login or sign up in order to post.