How do I get the value of a button using $ _REQUEST?

0

Good evening. I do a query, I load the data to a table and in each row I have a button that every record will have a different value. My question is how to get, in php, the value of the selected button using $ _REQUEST. The value I can echo is always the value of the first button. How do you do this with $ _REQUEST? I also accept other suggestions!

This is my button

<button type="button" name="ver_ee" data-toggle="modal" data-target="#myModal3" style="background-color: Transparent; border: none;" value=' . $registos[0] . '><i class="fa fa-male"></i></button>

This is the code to echo the value of the

<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <h2 class="modal-title" id="myModalLabel">Encarregado de educação</h2>
                                            </div>
                                            <div class="modal-body">
                                                <?php
                                                    $a = $_REQUEST["ver_ee"];
                                                    echo $a;
                                                ?>
                                            </div>
                                            <div class="modal-footer">
                                                <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
                                                <input type='button' data-dismiss="modal" name='cancelar' class="btn" value='Fechar' /> 
                                            </div>
                                        </div>
                                    </div>
                                </div>
    
asked by anonymous 23.05.2018 / 22:08

1 answer

0

See if this example helps you:

Create a test.php file and put it in your hosting, in the example below I used localhost, you can change it if you want:

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Exemplo Simples</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
    <div class="container">
        <?php

        if(isset($_REQUEST['id']) && isset($_REQUEST['titulo'])){
            $result =  '<div class="alert alert-success" role="alert">';
            $result .= "Você está editando o registro com ID ". $_REQUEST['id'] . " e com o título " . $_REQUEST['titulo'];
            $result .= '</div>';
            echo $result;
        }
        ?>
        <div class="table-responsive">
            <table class="table">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Titulo</th>
                    <th>Editar</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>1</td>
                    <td>Primeiro titulo</td>
                    <td><a class="btn btn-primary" href="/teste.php?id=1&titulo=Primeiro titulo" role="button">Editar</a></td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Segundo titulo</td>
                    <td><a class="btn btn-primary" href="/teste.php?id=2&titulo=Segundo titulo" role="button">Editar</a></td>
                </tr
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>
    
24.05.2018 / 07:00