PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 4, 2022

[FIXED] I can't list properly in table in CodeIgniter

 March 04, 2022     codeigniter, html, php     No comments   

Issue

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>


Answered By - Piketty Thoma
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing