数据检索问题

I'm actually working on a vendors and clients kind of a website, so basically client orders services from different kinds of vendors.

I have a table in database named "orders" which consists of all the order details like client email, vendor email, and the order status. So, in the vendor section, I want to display all the orders related to that particular vendor. So, for the basic information I joined the tables and retrieved client details and order details.

Here below is a function in my controller,

    public function customers()
{
    if($this->session->userdata('is_logged_in') == 1)
    {
        $this->output->enable_profiler(TRUE);


        $this->load->model('Model_vendor');
        $data['services'] = $this->Model_vendor->get_services_ordered();

      $this->load->view('inc/header_vin');
      $this->load->view('vendor/dashboard/customers',$data);
      $this->load->view('inc/footer');

    }
    else 
    {
      redirect("vendor/login");
    }

}

Below is my model function

public function get_services_ordered()
{
    $email = $this->session->userdata('email');



    $this->db->select('*');
    $this->db->where('vendor_email',$email);
    $query = $this->db->query('SELECT * FROM orders a JOIN client b on a.`client_email`= b.`email`');

    if($query)
        return $query->result();
    else
        return false;

}

Here is my view

  <?php
             $i=0;

            foreach($services as $service): ?>

      <div class="row">


          <div class="panel with-nav-tabs panel-default">

              <div class="panel-heading">
                  <ul class="nav nav-tabs">
                      <li class="active"><a href="#tab1default" data-toggle="tab">Client Profile</a></li>
                      <li><a href="#tab2default" data-toggle="tab">Service Obtained</a></li>
                      <li><a href="#tab3default" data-toggle="tab">Work Status</a></li>
                      <li><a href="#tab4default" data-toggle="tab">Documents</a></li>
                      <li><a href="#tab5default" data-toggle="tab">Messages</a></li>

                  </ul>
              </div>

              <div class="panel-body">
                  <div class="tab-content">
                      <div class="tab-pane fade in active" id="tab1default">


                          <strong> Customer Name </strong> : <?php echo $service->first_name; ?> <?php echo $service->last_name; ?>   <br>
                          <strong> Email </strong> : <?php echo $service->client_email; ?>  <br>
                          <strong> Phone No </strong> : <?php echo $service->mobile; ?>      <br>


                      <strong>Work Status </strong> : Initiated      <br>
                      <strong>Documents Requested</strong> : Main Plan      <br>
                      <strong>Documents Submitted</strong> :        <br>

                  </div>
                  <div class="tab-pane fade" id="tab2default">

                  <strong>Service Requested </strong> :


                  </div>
                  <div class="tab-pane fade" id="tab3default">Default 3</div>
                  <div class="tab-pane fade" id="tab4default">Default 4</div>
                  <div class="tab-pane fade" id="tab5default">Default 5</div>
              </div>
                    </div>
             </div>
        </div>

      </div>

      <?php endforeach; ?>

The problem is there are many orders, each order maybe from different client. So how can I retrieve data from other database tables regarding a particular order id ? As I'm actually using bootstrap tabs I want to display download links for particular order ID in a tab. So how can I display these download links using ajax or any other way?

i recommend u to use active record like this:

$this->db->select('*');
$this->db->from('orders'); 
$this->db->join('client', 'client.client_email = orders.email'); 
$query = $this->db->get();

========================================================================

and for the view if u want to create some tables with db data i recommend u to use jquery-bootgrid, they give u a lot of examples. http://www.jquery-bootgrid.com/Documentation