session comparison with a database field in php

0

I need some help. I have a table in the bank called texts which in turn has a student column that receives the emails of who is saving texts there. In this page, a table has to be generated for each student's text in that particular email, that is, I have to compare the email saved in the session with the emails of the student column of the texts table and generate tables only for the student texts of that specific email . But I do not know if I did it right in that if within the while. Can you help me?

<?php require_once ("cabecalho2.php");
    require_once ("../model/banco-usuario.php");
    session_start();
    $consulta = "SELECT titulo, data, aluno FROM textos";
    $result = $conexao->query($consulta);
    ?>

    <main>
        <div class="row">
            <?php while($dados = $result->fetch_array()){
                $titulo = $dados["titulo"];
                $data = $dados["data"];
                $aluno = $dados['aluno'];
                if($_SESSION('login') = $aluno;){

                    $tabela ='<div class="col l10 s11 offset-s1" style="border: #006064 solid 3px; padding: 0px; border-radius: 6px; margin-bottom: 10px;">';
                    $tabela .= '<div class="card-panel cyan darken-4 z-depth-0" style="margin-top: 0px; border-radius: 0px; margin-bottom: 0px; padding: 3px 9px 3px 9px;">';
                    $tabela .= '<h5 class="white-text light center-align" style="margin: 6px; font-size: 18px;">Tema:';
                    $tabela .= '</h5>';
                    $tabela .= '</div>';
                    $tabela .= '<div class="card-panel N/A transparent z-depth-0 col l12 s12" style="padding: 10px; margin: 0px;">';
                $tabela .= '<table class="highlight centered">';//abre table
                $tabela .='<thead>';//abre cabeçalho
                $tabela .= '<tr>';//abre uma linha
                $tabela .= '<th>Título da Redação</th>'; // colunas do cabeçalho
                $tabela .= '<th>Status da Correção</th>';
                $tabela .= '<th>Data de Envio</th>';
                $tabela .= '<th>Prazo de Entrega</th>';
                $tabela .= '<th>Ação</th>';
                $tabela .= '</tr>';//fecha linha
                $tabela .='</thead>'; //fecha cabeçalho
                $tabela .='<tbody>';//abre corpo da tabela
                /*Se você tiver um loop para exibir os dados ele deve ficar aqui*/
                $tabela .= '<tr>'; // abre uma linha
                $tabela .= '<td>'.$titulo.'</td>'; //coluna numero
                $tabela .= '<td>Corrigida</td>'; // coluna validade
                $tabela .= '<td>'.$data.'</td>'; //coluna anexo
                $tabela .= '<td>15 dias</td>';//coluna valor numero
                $tabela .= '<td><i class="small material-icons">done</i></td>'; // coluna data
                $tabela .= '</tr>'; // fecha linha
                /*loop deve terminar aqui*/
                $tabela .='</tbody>'; //fecha corpo
                $tabela .= '</table>';//fecha tabela
                $tabela .= '</div>';
                $tabela .= '</div>';

                echo $tabela;
            }
        }?>

    </div>
    </main>

    <?php include 'rodape.php';
    die();?>
    
asked by anonymous 25.07.2017 / 16:34

1 answer

0

I do not quite understand, do you want to get only the emails of the student in question? (What is logged in?)

If it is, try doing something like:

$consulta = "SELECT titulo, data, aluno FROM textos WHERE aluno = '".$_SESSION['login']."'";

Remove this line too, after all, we passed the comparison in the search of the bank

if ($ _ SESSION ('login') = $ student;) {

Do not forget to remove the rest.

NOTE: I imagine that what is stored in the login session is what will compare in the database, otherwise, switch to the correct

    
25.07.2017 / 17:09