我必须显示一个新的字段计数.即表中每个要求 ID jil_mrorfq计数


i have to show a new field count.that is the count of each requirement id in jil_mrorfq table

我有一个管理页面,其中包含要求服务、发布者、管理者、数量、发布日期、表格要求中的状态等字段。 我必须显示一个新的归档计数。即表中每个要求 ID jil_mrorfq计数。我完成了管理的部分,但我不知道如何显示计数,它如何与此代码一起获取。任何人都知道查询,请帮助我完成此任务。我正确地完成了分页的管理页面。但是每个要求 ID 的计数必须显示为表中的下一个字段。我完全困惑它是如何获取的。查询将如何写入。任何人都知道答案,那么请帮助我完成此任务。

我的控制器

public function managerequirement() {
        $this->load->helper(array('form', 'url'));
        $this->load->view('moderator/templates/header');
        $this->load->view('moderator/templates/sidebar');
        $this->load->library('pagination');
        $config = array();
        $config["base_url"] = base_url() . "moderator/Requirement/managerequirement";
        $config["total_rows"] = $this->requirement_model->record_count();
        $config["per_page"] = 20;
        $config["uri_segment"] = 4;
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = 'first';
        $config['last_link'] = 'last';
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['prev_link'] = '&laquo';
        $config['prev_tag_open'] = '<li class="prev">';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(4)) ? $this->uri->segment(4) :0;
        $data["results"]= $this->requirement_model->
                fetch_data($config["per_page"], $page); 
        $data["links"] = $this->pagination->create_links();
        $this->load->view('moderator/managerequirement', $data);
        $this->load->view('moderator/templates/footer');
    }

我的模型

 public function fetch_data($limit, $start) {
        $this->db->limit($limit, $start);
         $this->db->from('jil_requirements');
          $this->db->join('jil_users', 'jil_requirements.rqm_userid=jil_users.usr_id', 'left');
           $this->db->join('jil_merchants', 'jil_requirements.rqm_createdempid=jil_merchants.mer_id', 'left');
           $this->db->where('jil_requirements.rqm_permission!=', '4');
        $query =  $this->db->get();  
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                 $data[] = $row;
            }
           return $data;
        }
        return false;
   }

视图

 <div class="col-xs-12">
                                <table class="table table-bordered table-hover table-striped">
                                    <tr role="row">
                                        <th class="sorting" width="5%">#</th>
                                        <th class="sorting" width="30%">Requirement Service</th>
                                        <th class="sorting" width="10%">Posted By</th>
                                        <th class="sorting" width="10%">Managed By</th>
                                         <th class="sorting" width="15%">Quantity</th>
                                        <th class="sorting" width="15%">Posted  On</th>
                                        <th class="sorting" width="15%">Status</th>

                                    </tr>
                                    <?php
                                     if(!empty($results))
                                    {
                                    foreach ($results as $row) {
                                        ?><tr>  
                                            <td class=" "><?php echo $row->rqm_id; ?></td>  
                                            <td class=" ">   <a href="<?php echo base_url() . 'moderator/Requirement/viewrequirementdetails/' . $row->rqm_id ?>"><?php echo $row->rqm_service; ?></a></td>
                                           <td class=" "><?php
                                           echo $row->usr_name;
                                           ?></td>  
                                           <td class=" "><?php
                                           echo $row->mer_name;
                                           ?></td>  
                                             <td class=" "><?php
                                           echo $row->rqm_quantity;
                                           ?></td>  
                                             <td class=" "><?php echo date('d-M-Y',$row->rqm_dated);?></td>  
                                             <td class=" "><?php 
                                             if($row->rqm_permission=='0')
                                             {
                                                 echo "In-Active";
                                             }
                                            else if($row->rqm_permission=='1')
                                             {
                                                 echo "Active";
                                             }
                                               else if($row->rqm_permission=='2')
                                             {
                                                 echo "Pending";
                                             }
                                               else if($row->rqm_permission=='3')
                                             {
                                                 echo "Suspend";
                                             }
                                               else if($row->rqm_permission=='4')
                                             {
                                                 echo "Delete";
                                             }
                                             ?></td>  
                                        </tr>  
                                    <?php }
                                    }
                                    ?>  
                                </table>
                                <?php echo $links; ?>   
                            </div> 

使用以下代码

  public function fetch_data($limit, $start) {
      $this->db->limit($limit, $start);
      $this->db->from('jil_requirements');
      $this->db->join('jil_users', 'jil_requirements.rqm_userid=jil_users.usr_id', 'left');
      $this->db->join('jil_merchants', 'jil_requirements.rqm_createdempid=jil_merchants.mer_id', 'left');
      $this->db->where('jil_requirements.rqm_permission!=', '4');
      $query =  $this->db->get();  
      if ($query->num_rows() > 0) {
      foreach ($query->result() as $row) {
          $this->db->select('count(jil_mrorfq.rfq_requirementid) as total'); 
          $this->db->from('jil_mrorfq'); 
          $this->db->where('jil_mrorfq.rfq_requirementid',$row->rqm_id);
          $this->db->group_by('jil_mrorfq.rfq_requirementid'); 
          $query2= $this->db->get()->row_object();
         $row->total_count = $query2->total;
         $data[] = $row;
                }
               return $data;
            }
            return false;
       }

试试这个编码

  public function fetch_data($limit, $start) {
            $this->db->limit($limit, $start);
             $this->db->from('jil_requirements');
              $this->db->join('jil_users', 'jil_requirements.rqm_userid=jil_users.usr_id', 'left');
               $this->db->join('jil_merchants', 'jil_requirements.rqm_createdempid=jil_merchants.mer_id', 'left');
               $this->db->where('jil_requirements.rqm_permission!=', '4');
            $query =  $this->db->get();  
            if ($query->num_rows() > 0) {
                foreach ($query->result() as $key=>$row) {
                     $data[$key] = $row;
$this->db->select('jil_mrorfq.rfq_requirementid'); 
$this->db->from('jil_mrorfq'); 
$this->db->join('jil_requirements', 'jil_requirements.rqm_id=jil_mrorfq.rfq_requirementid', 'left');
 $this->db->group_by('jil_requirements.rqm_id'); 
$query2= $this->db->get();
 $data[$key]['count'] =$query2->num_rows();
                }
               return $data;
            }
            return false;
       }
相关文章:
  • 没有找到相关文章