How do for my list shows only the items you have user_id={$_SESSION['id']

Asked

Viewed 43 times

1

<?php 
echo "<table class='table'>";
echo "<thead>";
echo "<tr>";
echo "<th>id</th>";
echo "<th>nome</th>";
echo "<th>descriçao</th>";
echo "<th>resquisito</th>";
echo "<th>previsao da data</th>";
echo "<tbody>";
echo "</thead>";
echo "<tbody>";
echo "<tbody id='table_page'>";

foreach ($tarefas as $taf ) {
  echo "<tr>";
  echo "<td style='padding-right:10px'>" .$taf->tarefa_id . "</td>";
  echo "<td>" . $taf->tarefa_nome . "</td>";
  echo "<td>" . $taf->tarefa_descricao . "</td>";
  echo "<td>" . $taf->tarefa_minimo . "</td>";
  echo "<td>" . $taf->tarefa_data . "</td>";
  echo "<td align='center'> <span name='opc' id='visualizar'  data-target='#gridSystemModal'  ><i class='fa fa-cog' aria-hidden='true'></i></span></td>";
}
?>  


public function index($indice=null) {
    $this->load->database();
    $this->db->select('*');
    $dados['tarefas'] = $this->db->get('tarefa')->result();
    $this->load->view('includes/html_header');
    $this->load->view('includes/menu');
    $this->load->view('listadetarefasv', $dados);
    $this->load->view('includes/html_footer');
}
}

How to do for my list shows only the items you have usuario_id={$_SESSION['id'].

1 answer

2


I believe that adding an if before printing the table will solve your problem.

Assuming the Taf record has within it the value of the user id:

  foreach ($tarefas as $taf ) {
      if($taf->usuario_id == {$_SESSION['id']){
        echo "<tr>";
        echo "<td style='padding-right:10px'>" .$taf->tarefa_id . "</td>";
        echo "<td>" . $taf->tarefa_nome . "</td>";
        echo "<td>" . $taf->tarefa_descricao . "</td>";
        echo "<td>" . $taf->tarefa_minimo . "</td>";
        echo "<td>" . $taf->tarefa_data . "</td>";
        echo "<td align='center'> <span name='opc' id='visualizar'  data-target='#gridSystemModal'  ><i class='fa fa-cog' aria-hidden='true'></i></span></td>";
      }
    }
    ?>  

See if it works.

Browser other questions tagged

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