Modal view with mysql database list

Asked

Viewed 28 times

0

Hello, I have a database that is being displayed in a list on my site but I want to put a button to open a modal and display the information of each db line but whenever I open the modal it only displays the last line of records.

The code used to

while ($row_produto = mysqli_fetch_assoc($result_produtos)) {
            # code...
                echo "<section>"
             . "<span>Tema : " . $row_produto['tema'] . "</span><br>"
             . "<span>ID : " . $row_produto['id_nec'] . "</span>"
             . "<div class='div_pai-btn'>"
             . "<input class='btn_edit-prod btn_prod' type='button' value='Editar Produto'>"
             . "<input class='btn_add-prod btn_prod' type='button' value='Adicionar Imagem'>"
             . "<input class='btn_exc-prod btn_prod' type='button' value='Excluir Produto'>"
             . "</div>"
             . "<div class = 'cont_img-prod'>"
             . " <img src = 'upload/" .$row_produto['id_nec'] . "/" .$row_produto['imagem'] ."'>"
             . " </div>"
             . " </section>"
             . " <hr>"
             .  "<div class='edit_modal'>
                     <span>Tema : " . $row_produto['tema'] . "</span>
                </div>";
        };

I appreciate the help from now on.

  • It has crossed your mind that the recommended use of ajax?

1 answer

0


You need to use javascript and ajax, pass the id of the array you want to search in the modal onclick, make a request via ajax and display the data in the modal. Modal also needs an id.

Browser other questions tagged

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