简体   繁体   中英

Codeigniter-Limit 2 image per page in window.print()

Good day everyone. So I have this working code that shows image from a folder using the image names that is saved in my database. So basically, Folder(image_name) = Table(image_name).

Model (print_model)

public function get_names($acknowledgement_key) {
    $query = $this->db->select('*')
            ->from('TblPrintImage')
            ->where('acknowledgement_key', $acknowledgement_key)
            ->order_by('img_id', 'asc')
            ->get();
    return $query->result();
}

View (print_view)

<?php foreach ($saved as $data) { ?>
 <div class="row">
  <div class="col-xs-12" >
   <br>
    <table class="table table-bordered table-condensed">
     <tr style="text-align: center;font-family: Times New Roman;font-size: 16px;color: black; font-weight: bolder">
      <td><br></td>
     </tr>
     <tr>
      <td>                                                                                
       <div class="row">
        <div class="col-xs-12">                                                                                        
         <img src="<?php echo base_url("./uploads/" . $data->img_name . ".jpg"); ?>" width="650" height="224" alt=""/>                                  
        </div>                                                          
       </div>                                                            
       <div class="row">                                                  
        <div class="col-xs-12" >                                                 
         <textarea class="form-control" style="overflow: hidden; resize: none; border: 0; background: transparent; font-size: 14px;" maxlength="500" rows="5" name="" id="" ><?php echo $data->findings ?>
         </textarea>                                                           
        </div>                                                           
       </div>                                                                            
      </td>
     </tr>
    </table>
   </div>
  </div>
 <?php } ?>

Controller (print_controller)

public function print($acknowledgement_key) {
$data ['saved'] = $this->print_model->get_names($acknowledgement_key);
$this->load->view('print_view', $data);
}

The PROBLEM is, because it was called as an array, it will also show in a group of an array like this in window.print();. 在此处输入图片说明

What I want is to limit in to 2 (two) image per page in window.print(); like this. 在此处输入图片说明 I hope that I explained this will because i've been stuck in solving this since yesterday. Thanks guys.

$this->db->limit(2); to limit results to the first two images.

What you want to achieve is known as Pagination in web development world. You have not implemented any pagination logic. You have to use Pagination to achieve desired result.

Refer this link for reference Pagination with CI .

I hope this will give you fair idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM