Search code examples
phphtmlcodeigniter

I can't list properly in table in CodeIgniter


It lists them all in the first column when viewing. Even though I separate it with it doesn't add to the second or third column. It continues to the bottom of the first column.

enter image description here

Controller Code

$data['post_verbs'] = $this->verb_model->get_verbs($post->id);

Model Code

    public function get_verbs($id)
    {
        $sql = "SELECT fiilcekimleri.*, fiiller.title AS fiil_title, fiiller.title_slug AS title_slug 
                FROM fiilcekimleri LEFT JOIN fiiller ON fiiller.id = fiilcekimleri.fiil_id 
                WHERE fiilcekimleri.fiil_id = ? AND fiilcekimleri.altZamanId = ? AND fiilcekimleri.durumTurId = ? ORDER BY fiilcekimleri.ozneTurId ASC";
        $query = $this->db->query($sql, array(clean_number($id)));
        return $query->result();
    }

View Code

<tbody> 
<?php foreach ($post_verbs as $verbs => $code):?> 
 <tr>
        
<?php if ($code->altZamanId == 2 AND $code->durumTurId == 1) { ?> 
<td> <?php echo $code->title; ?> </td> <?php } ?>
        
<?php if ($code->altZamanId == 2 AND $code->durumTurId == 2) { ?> 
<td> <?php echo $code->title; ?></td> <?php } ?>

</tr>
<?php endforeach; ?>

 </tbody>

Solution

  • Controller

        $data['post_1'] = $this->fiil_model->get_verbs($post->id, 2, 1);
        $data['post_2'] = $this->fiil_model->get_verbs($post->id, 2, 2);
        $data['post_3'] = $this->fiil_model->get_verbs($post->id, 2, 3);
        $data['post_4'] = $this->fiil_model->get_verbs($post->id, 2, 4);
    

    Model

        public function get_verbs($id, $altZamanId, $durumTurId)
    {
        $sql = "SELECT fiilcekimleri.*, fiiller.title AS fiil_title, fiiller.title_slug AS title_slug 
                FROM fiilcekimleri LEFT JOIN fiiller ON fiiller.id = fiilcekimleri.fiil_id 
                WHERE fiilcekimleri.fiil_id = ? AND fiilcekimleri.altZamanId = ? AND fiilcekimleri.durumTurId = ? ORDER BY fiilcekimleri.ozneTurId ASC";
        $query = $this->db->query($sql, array(clean_number($id), clean_number($altZamanId), clean_number($durumTurId)));
        return $query->result();
    }
    

    VIEW

                  <tbody>             
               <?php foreach ($post_1 as $verbs => $code):?>  
                <tr>                    
                  <td><?php echo $code->title; ?></td>
                  <td><?php echo  $post_2[$verbs]->title; ?></td>                                   
                  <td><?php echo  $post_3[$verbs]->title; ?></td>                                   
                  <td><?php echo  $post_4[$verbs]->title; ?></td>                                   
        
                </tr>
               <?php endforeach; ?>
    
               </tbody>