Welcome Guest, Not a member yet? Register   Sign In
I have trouble with sorting table when data I read from folder
#1

[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">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
[removed][removed]
&lt;/head&gt;

&lt;body&gt;
<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>



&lt;?php foreach($query as $r):?&gt;
&lt;?php $r= $r->cabang;?&gt;
&lt;?php echo $r;?&gt;
&lt;?php echo $dir; ?&gt;
&lt;?php foreach($p as $q):?&gt;

    <tr>
        
        <td width="280">&lt;?php echo $q['name'];?&gt; </p></td>
      <td width="130"><p align="right">&lt;?php echo $q['time'] ; ?&gt;</p></td>
       <td width="130"><p align="right">&lt;?php echo $q['size'] ;?&gt;</p></td>
      
       <td width="130"><p align="right">&lt;?php echo anchor("login/download_file/".$dir."/".$q['name'],"download"); ?&gt;</p></td>
      
      
      
        
    </tr>
    &lt;?php echo form_close(); ?&gt;
    &lt;?php endforeach ?&gt;
        &lt;?php endforeach ?&gt;
    <tr>
        
        
        
    </tr>
    <tr>

    </table>

    

&lt;/body&gt;
&lt;/html&gt;



tq for helping me..
#2

[eluser]codingmumet[/eluser]
pls help me..
#3

[eluser]metaltapimenye[/eluser]
salam met.

it simplier to use javascript for sorting generated tables.. fast, painfree, and no need to query
#4

[eluser]codingmumet[/eluser]
I have tried it.. but it did'nt worked.. have any idea..

tHq
#5

[eluser]codingmumet[/eluser]
pls help me.... help...
Sad
#6

[eluser]codingmumet[/eluser]
help me pls...pls..
#7

[eluser]codingmumet[/eluser]
help help... pls pls...
#8

[eluser]codingmumet[/eluser]
help...
#9

[eluser]metaltapimenye[/eluser]
ei met, jangan malu2in indolah.. coba dulu cara javascriptnya.
#10

[eluser]codingmumet[/eluser]
I already Tried but it didnt work..

tq u for ur help.. I apreciate that..




Theme © iAndrew 2016 - Forum software by © MyBB