Model view controller 生成的非功能数据表
我一直在尝试使用从codeigniter应用程序的datatable中获取数据库的输出。我遵循了所有的形式化方法,但不知何故,生成的数据表只是一个静态的无响应表。我正在下面粘贴我的代码 这是我的控制器:Model view controller 生成的非功能数据表,model-view-controller,datatables,codeigniter-3,Model View Controller,Datatables,Codeigniter 3,我一直在尝试使用从codeigniter应用程序的datatable中获取数据库的输出。我遵循了所有的形式化方法,但不知何故,生成的数据表只是一个静态的无响应表。我正在下面粘贴我的代码 这是我的控制器: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Datatable_Control extends CI_Controller { public function __co
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Datatable_Control extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
// $this->load->helper('url');
$this->load->model('order_dt');
$customer_list = $this->order_dt->getAllCustomers();
$data["customers_list"] = $customer_list;
$this->load->view("datatable", $data);
}
}
?>
这是我的模型:
<?php
class Order_dt extends CI_Model {
public function getAllCustomers(){
$this->load->database();
$query = $this->db->get('customers');
return $query->result();
}
}
?>
以下是我的看法:
<!DOCTYPE html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" language="javascript"
src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript"
src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css"
href="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css">
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#rahul').DataTable();
});
</script>
</head>
<body>
<div class="page-header">
<h1>CI-DataTables Library Example</h1>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
<table id="rahul">
<thead>
<tr>
<td><strong>Customer Number</strong></td>
<td><strong>Last Name</strong></td>
<td><strong>First Name</strong></td>
<td><strong>Phone</strong></td>
<td><strong>Address 1</strong></td>
<td><strong>Address 2</strong></td>
<td><strong>City</strong></td>
<td><strong>State</strong></td>
<td><strong>Postal Code</strong></td>
<td><strong>Country</strong></td>
<td><strong>Sales Emp No.</strong></td>
<td><strong>Credit Limit</strong></td>
</tr>
<?php foreach ($customers_list as $c): ?>
<tr>
<td><?php echo $c->customerNumber; ?></td>
<td><?php echo $c->customerName; ?></td>
<td><?php echo $c->contactLastName; ?></td>
<td><?php echo $c->contactFirstName; ?></td>
<td><?php echo $c->phone; ?></td>
<td><?php echo $c->addressLine1; ?></td>
<td><?php echo $c->addressLine2; ?></td>
<td><?php echo $c->city; ?></td>
<td><?php echo $c->state; ?></td>
<td><?php echo $c->postalCode; ?></td>
<td><?php echo $c->country; ?></td>
<td><?php echo $c->salesRepEmployeeNumber; ?>
</td>
<td><?php echo $c->creditLimit; ?></td>
</tr>
<?php endforeach ?>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
$(文档).ready(函数(){
$('#rahul')。数据表();
});
CI数据表库示例
客户编号
姓氏
名字
电话
地址1
地址2
城市
状态
邮政编码
国家
销售Emp编号
信用额度
我已经尝试并搜索了所有可能的方法来获得一个功能正常的数据表。我无法找出我的代码有什么问题,或者我遗漏了什么。请导游。我附上一张图片:
这个问题很愚蠢。我使用的是
标记中的表数据