[eluser]codingmumet[/eluser]
How I can sorting table data, where data I got from read folder?
controller function
Code:
function Folder_DPK_Giro_Jan()
{
$username = $this->session->userdata('username');
$data['query'] = $this->Login_model->getUser($username);
$cabang = $this->Login_model->getUser($username);
foreach($cabang as $row2)
{
$dir = ("cabang/".$row2->cabang."/DPKgiroJan");
}
//$tanggal = $this->input->post('TANGGAL');
$data['p'] = $this->Login_model->dir_list($dir);
$data['dir'] = "DPKgiroJan";
//$data['p'] = dir_list('test');
$username = $this->session->userdata('username');
$data['query'] = $this->Login_model->getUser($username);
$data['main_view'] = 'file_folder';
$this->load->view('template', $data);
}
Model Function
Code:
function getUser($username)
{
$this->db->select('no, username , cabang, level');
$this->db->from('user');
$this->db->where("username = '$username'");
//$this->db->get_where('user', array('username' => $username));
return $this->db->get()->result();
}
function dir_list($dir)
{
if ($dir[strlen($dir)-1] != '/') $dir .= '/';
if (!is_dir($dir)) return array();
$dir_handle = opendir($dir);
$dir_objects = array();
while ($object = readdir($dir_handle))
if (!in_array($object, array('.','..')))
{
$filename = $dir . $object;
$file_object = array(
'name' => $object,
'size' => filesize($filename),
// 'perm' => permission($filename),
// 'type' => filetype($filename),
'time' => date("d F Y H:i:s", filemtime($filename))
);
$dir_objects[] = $file_object;
}
return $dir_objects;
}
view model
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
[removed][removed]
</head>
<body>
<table class="sortable" id="anyid" cellpadding="0" cellspacing="0" width="501" border="1">
<tr>
<th>laporan</th>
<th>tanggal</th>
<th>Size</th>
<th>pilihan</th>
</tr>
<?php foreach($query as $r):?>
<?php $r= $r->cabang;?>
<?php echo $r;?>
<?php echo $dir; ?>
<?php foreach($p as $q):?>
<tr>
<td width="280"><?php echo $q['name'];?> </p></td>
<td width="130"><p align="right"><?php echo $q['time'] ; ?></p></td>
<td width="130"><p align="right"><?php echo $q['size'] ;?></p></td>
<td width="130"><p align="right"><?php echo anchor("login/download_file/".$dir."/".$q['name'],"download"); ?></p></td>
</tr>
<?php echo form_close(); ?>
<?php endforeach ?>
<?php endforeach ?>
<tr>
</tr>
<tr>
</table>
</body>
</html>
tq for helping me..