如何移动下一个和上一个票据编号(从数据库中获取)并使用codeiginter在视图页面中显示

时间:2018-10-29 05:18:42

标签: php codeigniter

 how to move previous and next billno and 
      view in the view page.


   public function Bill_Prev1(){

        $this->db->query('SELECT * from salesitem where billno = 1 AND 
      billno > 1 ORDER BY billno ASC LIMIT 1;')->result_array();
        $this->db->join('salesbill', 'salesbill.no = salesitem.billno','left 
    outer');
        $this->db->join('parmaster','parmaster.Pcode = 
      salesbill.partyname','left outer');
        $query = $this->db->get()->row();
        return $query;
          }

   public function Bill_Prev(){
   $query = $this->db->query('SELECT * from 
  salesitem where billno = 1 AND billno > 1 
     ORDER BY billno ASC LIMIT 1;')- 
   >result_array();


          return $query;
      }

这是模型代码..............

我的prblm是如何不使用codeiginter来移动上一个和下一个。...

1 个答案:

答案 0 :(得分:1)

传递当前的帐单编号和订单(下一个/上一个)。

public function Bill_NextPrev($billNo=0,$order='next'){
   if($order='next'){
      $this->db->where('s.billno >', $billNo);
   }else{
      $this->db->where('s.billno <', $billNo);
   }
   $this->db->limit(1);
   $this->db->from('salesitem as a');

   $query = $this->db->get();
   if( $query->num_rows() == 1 ){ 
     return  $query->result();
   }
   return false;
}