How can I apply bank information in the modal?

0

Well, I'm working on my computer-based CBT and its purpose is to control student output. I was able to do registration, delete system, I am already working on the edition, however I would like to implement a button that when clicking, will show more information of the student within a modal. I even managed to do this, but only the first record appears, for example:

The table contains Ana and Wilian. If I click to see the data of Ana, will appear everything cute, if I click the Wilian, will appear the data of Ana. If I reverse and put Wilian and then Ana, only Wilian data will appear.

PS: I've done a lot of research to try a solution, but I'm at the beginning of php and I learned only the PDO class, so I get confused with the "pure" php (if I can call it that).

<head>
    <title>MODAL</title>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--ARQUIVOS PADRÕES BOOTSTRAP-->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>

     <?php include("action_usuario.php")?>

    <div class="main register-form col-md-12">

        <ul class="list-group">
            <li class="list-group-item">
                <fieldset>
                    <form action="" method="get" id='form-contato' class="form-horizontal col-md-12 col-lg-12">
                        <div class='col-lg-6 col-md-7 col-sm-9 col-lg-offset-2 col-xs-12'>
                            <input type="text" class="form-control" id="termo" name="termo" placeholder="Infome o Nome/Matrícula">
                        </div>
                        <button type="submit" class="btn btn-primary col-lg-offset-0 col-xs-offset-2">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>&nbsp;
                        </button>
                        <a href='index.php' class="btn btn-primary">Ver Todos</a>
                    </form>
                </fieldset>
            </li>

            <li class="list-group-item">
                <?php if(!empty($usuarios)):?>

                    <!-- Tabela de Clientes -->
                <div class="table-responsive">
                    <table class="table table-bordered table-hover ">
                        <tr class='active'>
                            <th>Nome</th>
                            <th>Matrícula</th>
                            <th>Turma</th>
                            <th>Nível</th>
                            <th>Opções</th>
                        </tr>
                        <?php foreach($usuarios as $usuario):?>
                        <tr>
                            <td><?=$usuario->nome?></td>
                            <td><?=$usuario->matricula?></td>
                            <td><?=$usuario->turma?></td>
                            <td><?=$usuario->nivel?></td>
                            <td style="width:16%">


                            <a rel="<?=$usuario->matricula?>" id="view" name="view" class="btn btn-default text-center" role="button" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-eye-open"></span></a>

                                <div id="myModal" class="modal fade" role="dialog">
                                  <div class="modal-dialog">

                                    <!-- Modal content-->
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        <h3 class="modal-title"><?php echo $usuario->nome;?></h3>
                                      </div>
                                      <div class="modal-body">
                                        <p>Matrícula: <?php echo $usuario->matricula;?></p>
                                        <p>Turma: <?php echo $usuario->turma;?></p>
                                        <p>Email: <?php echo $usuario->email;?></p>
                                      </div>
                                      <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                      </div>
                                    </div>

                                  </div>
                                </div>



                            <a href="#editar.php?matricula=<?=$usuario->matricula?>" class="btn btn-primary text-center" role="button" disabled><span class="glyphicon glyphicon-pencil"></span></a>
                            <a href="#index.php?delete=<?=$usuario->matricula?>" class="btn btn-danger text-center" role="button" disabled><span class="glyphicon glyphicon-remove"></span></a>

                        </tr>   
                        <?php endforeach;?>
                    </table>
                    </div>


                    <?php else: ?>

                    <!-- Mensagem caso não exista clientes ou não encontrado  -->
                    <h5 class="text-center text-default">Não há registros cadastrados ou não correspondem à pesquisa!</h5>

                <?php endif; ?>

            </li>

        </ul>

    </div>

</body>

Inclusion, deletion, and search codes (in that order) of users.

<?php 

$conexao = conexao::getInstance();

if(isset($_POST['inserir'])){
    $matricula = $_POST['matricula'];
    $nome = trim(strip_tags($_POST['nome']));
    $turma = trim(strip_tags($_POST['turma']));
    $email = trim(strip_tags($_POST['email']));
    $login = trim(strip_tags($_POST['login']));
    $senha = trim(strip_tags($_POST['senha']));
    $nivel = trim(strip_tags($_POST['nivel']));

    $insert = "INSERT into tab_usuarios (matricula, nome, turma, email, login, senha, nivel) VALUES (:matricula, :nome, :turma, :email, :login, :senha, :nivel)";

        try{
        $result = $conexao->prepare($insert);
        $result->bindParam(':matricula', $matricula, PDO::PARAM_STR);
        $result->bindParam(':nome', $nome, PDO::PARAM_STR);
        $result->bindParam(':turma', $turma, PDO::PARAM_STR);
        $result->bindParam(':email', $email, PDO::PARAM_STR);
        $result->bindParam(':login', $login, PDO::PARAM_STR);
        $result->bindParam(':senha', $senha, PDO::PARAM_STR);
        $result->bindParam(':nivel', $nivel, PDO::PARAM_STR);
        $result->execute();
        $count = $result->rowCount();

        if($count>0){
            echo '<div class="alert alert-success">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <span class="glyphicon glyphicon-ok"></span> <strong>Usuário cadastrado com sucesso!</strong>
                    </div>';

            echo "<meta http-equiv=refresh content='1;URL=index.php'>";//refresh da pagina

        }else{
        echo '<div class="alert alert-danger">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <span class="glyphicon glyphicon-remove"></span> <strong>Não foi possivel cadastrar o usuário</strong>
                </div>';

        echo "<meta http-equiv=refresh content='1;URL=index.php'>";//refresh da pagina

        }

        }catch(PDOException $e){
                echo $e;
            }
}?>


<?php 

//exclusão de usuário
$conexao = conexao::getInstance();

if(isset($_GET['delete'])){
    $matricula = $_GET['delete'];

    $del = "DELETE from tab_usuarios WHERE matricula=:matricula";

    try{
        $result = $conexao->prepare($del);
        $result->bindParam(':matricula',$matricula, PDO::PARAM_INT);                
        $result->execute();
        $count = $result->rowCount();
        if($count>0){
            echo '<div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <span class="glyphicon glyphicon-ok"></span> <strong>Usuário deletado com sucesso!</strong>
                </div>';

            echo "<meta http-equiv=refresh content='1;URL=index.php'>";//refresh da pagina

            }else{
                echo '<div class="alert alert-msgstatus alert-danger alert-dismissable col-md-6 col-xs-6 col-6 col-md-offset-3  col-xs-offset-3 col-offset-3">
                        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                        <strong>Houve um erro ao deletar o cadastro.</strong>
                    </div>';    

            echo "<meta http-equiv=refresh content='1;URL=index.php'>";//refresh da pagina
        }

    }catch (PDOWException $erro){ echo $erro;}
}?>

<?php

// Recebe o termo de pesquisa se existir
$termo = (isset($_GET['termo'])) ? $_GET['termo'] : '';

// Verifica se o termo de pesquisa está vazio, se estiver executa uma consulta completa
if (empty($termo)):


    $conexao = conexao::getInstance();
    $sql = "SELECT * FROM tab_usuarios ORDER BY nome ASC "; //LIMIT $inicio, $quantidade
    $stm = $conexao->prepare($sql);
    $stm->execute();
    $usuarios = $stm->fetchAll(PDO::FETCH_OBJ);

else:

    // Executa uma consulta baseada no termo de pesquisa passado como parâmetro
    $conexao = conexao::getInstance();
    $sql = 'SELECT * FROM tab_usuarios WHERE nome LIKE :nome OR matricula LIKE :matricula OR turma LIKE :turma ORDER BY nome ASC ';
    $stm = $conexao->prepare($sql);
    $stm->bindValue(':nome', $termo.'%');
    $stm->bindValue(':matricula', $termo.'%');
    $stm->bindValue(':turma', $termo.'%');
    $stm->execute();
    $usuarios = $stm->fetchAll(PDO::FETCH_OBJ);

endif; ?>

In case you need it, I may be making a compressed with the work files available for ease of use. Thank you in advance and sorry for the lack of skill.

    
asked by anonymous 26.02.2017 / 16:23

0 answers