I need to display all the modes saved in the bank

1

I have a page, which needs to display all the modalities linked to it in the database, when I need to display everything in the database, in php I use mysqli_fetch_assoc and display everything, but the modal is called via javascript, and this does not work with mysqli, it displays the first normal modal, but I can not display the others.

Modal code

<div class="modal fade" id="myModal<?= $col2['id'] ?>" tabindex="-1" role="dialog"
                         aria-labelledby="exampleModalLabel"
                         aria-hidden="true">
                        <form method="post" action="" id="ajaxModal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="exampleModalLabel">Quiz Brutus</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>

                                <div class="modal-body">
                                    <h3><?= $col2['pergunta']; ?></h3>
                                    <input type="hidden" name="idPagina" value="<?= $col['id'];?>">
                                    <input type="hidden" name="pergunta" value="<?= $col2['pergunta']; ?>">
                                    <hr>
                                    <label for="radio"><input type="radio" id="radio" name="resposta"
                                                              value="<?= $col2['resposta1']; ?>"> <?= $col2['resposta1']; ?>
                                    </label>
                                    <hr>
                                    <label for="radio2"><input type="radio" id="radio2" name="resposta"
                                                               value="<?= $col2['resposta2']; ?>"> <?= $col2['resposta2']; ?>
                                    </label>
                                    <hr>
                                    <label for="radio3"><input type="radio" id="radio3" name="resposta"
                                                               value="<?= $col2['resposta3']; ?>"> <?= $col2['resposta3']; ?>
                                    </label>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" id="salvar" class="btn btn-primary">Salvar
                                    </button>
                                    <button class="btn btn-secondary" data-dismiss="modal">Fechar
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

javascript that will call it.

 <?php
    $select_quiz = "SELECT * FROM quiz WHERE idpagina = '$idPagina'";
    $result_selectQuiz = $conn->query($select_quiz);
    while($col3 = mysqli_fetch_assoc($result_selectQuiz)):
    ?>
    if (ddd11.indexOf(cidade) != -1 || ddd13.indexOf(cidade) != -1 || ddd15.indexOf(cidade) != -1) {
        // alert(rua + " - " + cidade + " - " + estado + " - " + pais);
        $(function {
           $('#myModal<?= $col3['id']; ?>').modal('show');

            });

    }
    else {
        $(function () {
            $('#myModal2').modal('show');

        });
    }
        jQuery(document).ready(function(){
            jQuery('#ajaxModal').submit(function(){
                var dados = jQuery( this ).serialize();

                jQuery.ajax({
                    type: "POST",
                    url: "functions/modalQuiz.php",
                    data: dados,
                    success: function()
                    {
                        $('#myModal<?= $col3['id']; ?>').modal('hide');

                    }
                });

                return false;
            });
        });

    <?php endwhile; ?>
}
    
asked by anonymous 08.10.2018 / 16:11

0 answers