Change table in mysql

1

I have the following situation.

A table that displays the search results in mysql, and inside that table I have a column where the edit button is. How do I make this button edit content displayed on that line?

I'm using the while loop to display them, and as far as I know, the while loop does not count what was displayed / found first or second. Right?

For example; in the code below I used mysql to search the "request" table for everything that has the word "Waiting ..." in the status column. The while loop will display one by one in order to find, and display more or less like this:

ID | Produto   | Valor | Cód. Pedido | Situação      | Editar
 1 | Produto 1 | 1.00  | 321         | Aguardando... | Botão Editar

And so it goes, ID 2, Product 2 and so on.

How can I make the button at the end of the table edit within the mysql line that it is?

<section class="news">
        <div class="page-reader">
            <h3>Lista de Pedidos <small>atualizado em <?= date("d/m/Y") ?></small></h3>
        </div>
        <table class="table table-striped">
            <tr>
                <td>ID</td>
                <td>Produto</td>
                <td>Valor</td>
                <td>Código do Pedido</td>
                <td>Situação</td>
                <td>Editar Pedido</td>

                <!-- Coloca os dados em um Array -->
                <?php 
                while ($resultado = mysqli_fetch_assoc($dados)) { ?>
            </tr>
                <td><?= $resultado['id']; ?></td>
                <td><?= $resultado['produto']; ?></td>
                <td><?= "R$ ". number_format($resultado['valor'],2); ?></td>
                <td><?= $resultado['pedido']; ?></td>
                <td><?= $resultado['status']; ?></td>
                <td><button type="button" class="btn btn-primary">Confirmar</button> <button class="btn btn-danger">Cancelar</button></td>
                <?php
                }
                 ?>
            </table>
    </section>
    
asked by anonymous 14.03.2015 / 02:42

1 answer

1

Good Rafael, the easiest alternative would be to generate an edit button for each line. That is.

Generate a button in the while or a <a> and pass the edit url together with the id returned in the query

Example:

<a href="editar.php?linha=$resultado['id']" />
    
17.05.2016 / 18:17