[eluser]pistolPete[/eluser]
Please use [ code ] tags in future posts!
I wouldn't use the table class but generate the table manually:
Controller:
Code:
<?php
class Customer extends Controller {
function customers_list()
{
$this->load->model('customer_model');
$data['all_customers'] = $this->customer_model->get_all();
$this->load->view('customer_list',$data);
}
function delete($id)
{
//...
}
function edit($id)
{
//...
}
}
Model:
Code:
<?php
class Customer_model extends Model
{
public function get_all()
{
$query = $this->db->get('customer');
if ($query->num_rows() > 0)
{
return $query;
}
else
{
return FALSE;
}
}
}
View:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Customers List</title>
<style type="text/css">
body {
font: small/1.5em Verdana, Arial, Helvetica, serif;
}
</style>
</head>
<body>
<h1>List of Customers</h1>
<table border="1" cellpadding="2" cellspacing="1" class="c_table">
<thead>
<tr>
<th>Customer ID</th>
<th>Customer Name</th>
<th>Owner Name</th>
<th>Place</th>
<th>Phone-1</th>
<th>Phone-2</th>
<th>Phone-3</th>
<th>Preffered Lorry Transport</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
/**
* You probably need to change the values of the fields below, e.g. $customer->id
* You need to use the same field names as in your database!
*/
foreach($all_customers->result() as $customer):
?>
<tr>
<td><?php echo $customer->id;?></td>
<td><?php echo $customer->name;?></td>
<td><?php echo $customer->place;?></td>
<td><?php echo $customer->phone1;?></td>
<td><?php echo $customer->phone2;?></td>
<td><?php echo $customer->phone3;?></td>
<td><?php echo $customer->lorry;?></td>
<td><?php echo $customer->id;?></td>
<td><?php echo site_url('customer/edit/'.$customer->id);?></td>
<td><?php echo site_url('customer/delete/'.$customer->id);?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</body>
</html>