如何从codeigniter中的视图中获取数据

I'm not good in codeigniter i'm still learning this. So i need your help guys.

I want to get the data from the database that the id is equal to the value of the dropdown list button.so heres is my code.

This is my controller: controller.php

function getdataload(){
     $this->load->view('data',$data);
}

I really don't know what to put in the controller.

This is my view: view.php

<html>
<body>
<label for="member">Member</label>
            <select class="form-control" id="member" name="member" required onchange="showCustomer(this.value)">
              <option selected="" value="">--select--</option>
                 <?php foreach ($members as $row): ?>
              <option value="<?php echo $row->mem_id; ?>"><?php echo ucwords($row->mem_fname.' '.$row->mem_lname) ?></option>
               <?php endforeach ?>
            </select>
</body>
</html>
<script>
$('#member').on('change',function(){
    $.post('<?php echo base_url("transactions/getdataload")?>',
        {
            mem_id:$(this).val()
        }).done(function(res)
        {
        $('#select_member').text(res);
    });
});
</script>

This is the other view that the called from the controller data.php

<?php

$q = intval($_GET['member']);

$con = mysqli_connect('localhost','root','','global89_point');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"global89_point");

$sql="SELECT * FROM loading_service WHERE member='".$q."'";
$result = mysqli_query($con,$sql);

echo "<table>";
echo "<tr>";
echo " <th>";
echo "Member ID";
echo "</th>";

echo "</tr>";

while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['member'] . "</td>";
    echo "</tr>";
}
echo "</table>";
mysqli_close($con);

?>

please help me with this guys.

You should call database lib from controller if you do not use models and database logic write to controller see this:

public function result()
{
    $this->load->library('database')
    $data = array();

    $service_list = $this->db->query("SELECT * FROM loading_service WHERE member='".$q."'")->result_array();
    $data['service'] = $service_list;
    $this->load->view('result', $data);
}

Here result view you get $service array and you can easily iterate this.

     Our model in CodeIgniter will be placed in application/models/form_model.php 

       <?php

        class Form_model extends Model {
        function Formmodel() {
        // load the parent constructor
        parent::Model();
        }
        function submit_posted_data() {
        // db is initialized in the controller, to interact with the database. 
        $this->db->insert('loading_service ',$_POST);     
        }
        function get_all_data() {
        // again, we use the db to get the data from table ‘form’
        $data['result']=$this->db->get('loading_service');
        return $data['result'];
        }
        }
        ?>


    controller

    ss Form extends Controller {
    function Form(){
    // load Controller constructor
    parent::Controller();
    // load the model we will be using
    $this->load->model('form_model');
    // load the database and connect to MySQL
    $this->load->database();
    // load the needed helpers
    $this->load->helper(array('loading_service','url'));
    }
    //Display the posted entries
    function index() {
    $data['member']='Form Data';
    //use the model to get all entries
    $data['result'] = $this->form_model->get_all_data();
    // load 'forms_view' view
    $this->load->view('forms_view',$data);
    }          
    //Process the posted loading_service
    function submit() {
    //use the model to submit the posted data
    $this->form_model->submit_posted_data();
    redirect('loading_service');
    }
    }
    ?>

you can refer this code..It will helpful for u...