How do I get an input text value?

Asked

Viewed 17,276 times

0

within that input there is an ID number, I would use that ID to do a search in the bank. how do I get this ID that is in an input text and "game" in php for me to use it as a search? should one do something like this? below:

                    <form method="get" action="">
                        Valor ID <input type="text" name="id-da-tabela-para-modal" id="id-da-tab-para-modal">
                    </form>

for now it’s like this:

                <div class="modal-body">                        
                        Valor ID <input type="text" name="id-da-tabela-para-modal" id="id-da-tab-para-modal">                       
                    <?php
                    require('conexao.php');
                    $id = $_GET['id-da-tab-para-modal'];
                    $resultado = mysql_query("select * from jogo Where ID=$id");
                    echo "<table class='table'>".
                        "<thead>".
                        "<tr>".
                        "<td>ID</td>".
                        "<td>Nome</td>".
                        "<td>Conta</td>".
                        "<td>Resultado</td>".
                        "<td>Valor Digitado</td>".
                        "<td>Dificuldade</td>".
                        "<td>Score</td>".
                        "</tr>".
                        "</thead>";
                    echo "<tbody>";
                    while($valores=mysql_fetch_array($resultado)){
                        echo "<tr>".
                            "<td>".$valores['ID']."</td>".
                            "<td>".$valores['nome']."</td>".
                            "<td>".$valores['conta']."</td>".
                            "<td>".$valores['resultado']."</td>".
                            "<td>".$valores['dificuldade']."</td>".
                            "<td>".$valores['totalacertos']."</td>".
                            "</tr>";
                    }
                    echo "</tbody></table>";
                    @mysql_close(conexao);
                    ?>
                </div>

is not working.

1 answer

4


Voce wrote:

$id = $_GET['id-da-tab-para-modal'];

In fact it is

$id = $_GET['id-da-tabela-para-modal'];

After all, the name parameter of your input is id-from-table-to-modal

  • tidy, I didn’t notice this part, but it still didn’t work, I have to create a form with a Ubmit button to get the value of input text, right? There is some way to do it without the "submit button"?

  • Voce can do Submit with javascript. Anyway you have to submit. What do you want to do? whether the search is done after pressing a type enter key or the search is done while the user enters the value?

  • i wanted to do something like this: http://jsfiddle.net/4j59z60e/16/ my idea was to open a modal with more information from the player when he presses the "click" button, the previous table is just a small sample, If he wants to see more information about his game he will have to click the "click" button. on the modal screen where there is an input text is passed the ID clicked from the previous table, from this ID I will do a search in the database to know what information should be printed.

  • You will need ajax to do this. I suggest taking a look at the JS knockout. It is a very interesting tool and it is very quiet to learn. the Site has a fantastic tutorial.knockoutjs.with

  • Please ask your question as resolved if possible. Thank you :)

Browser other questions tagged

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