Welcome Guest, Not a member yet? Register   Sign In
problem count rows on table in pagination?
#1

[eluser]SaSa[/eluser]
I have an problem with rownum in following code. it is this that, in each page of pagination rows in table be counted from the beginning. For example, the clear:

P1: If we're on the first page of pagination, rows are the counts:
Code:
1 Columns1
2 Columns2
3 Columns3
4 Columns4
P2: If we're on the second page of pagination, rows are the counts:
Code:
1 Columns5
2 Columns6
3 Columns7
4 Columns8
<br>

P2: The I want to be counted row in table,(on the second page of pagination and ...):
Code:
5 Columns5
6 Columns6
7 Columns7
8 Columns8
P3: ... and more

This code:
Code:
$data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.* ".
            "FROM (SELECT @rownum:=0) r, hotel_submits t ".
            "ORDER BY id desc LIMIT $offset, 4");
Full code:
Code:
function show($offset = 0)
        {
        $this->load->library('pagination');
            $config['base_url'] = base_url().'admin/accommodation/show';
            $config['uri_segment'] = 4;
            $config['total_rows'] = $this->db->count_all('hotel_submits');
            $config['per_page'] = '4';            
            
            $this->pagination->initialize($config);    
                $data['pagination'] = $this->pagination->create_links();                                        

            $offset = (int) $offset; // just to make sure nothing funky gets in here
            $data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.* ".
                "FROM (SELECT @rownum:=0) r, hotel_submits t ".
                "ORDER BY id desc LIMIT $offset, 4");
          
                ////////////////////////                                
                
                $this->load->view('admin/accommodation_submit_show', $data);
    }
How is it?
With respect
#2

[eluser]SaSa[/eluser]
More about this: I do not want that in each page of pagination, rows are counted from the beginning.
The next page will be counted on every prev page.

see this images:
http://i.stack.imgur.com/2QzSc.gif
http://i.stack.imgur.com/komL3.gif
http://i.stack.imgur.com/6RQIb.gif

my view:
Code:
<div class="table_show">
    <table>
        <tr>
                <th>&lt;input type="checkbox" name="remember_me" value="true" &gt;&lt;/th>
                <th>#</th>
                <th>نوع</th>
                <th>نام</th>
                <th>ستاره - نوع</th>
                <th>آدرس</th>
                <th>شماره تماس</th>
                <th>نمابر</th>
                <th>وب سایت</th>
                <th>ایمیل</th>
                <th>زمان ثبت</th>
        </tr>
    &lt;?php
    //echo $this->table->generate($results);    
        foreach ($results->result() as $row)
        {
                echo    '<tr><td>&lt;input type="checkbox" name="remember_me" value="true" &gt;&lt;/td>';
                echo    '<td>'.$row->rownum.'</td>';
                echo    '<td>'.$row->type.'</td>';
                echo    '<td>'.$row->name.'</td>';
                echo    '<td>'.$row->star.' - '.$row->type_star.'</td>';                                
                echo    '<td><span id="'.$row->address.'" class="tooltip">'.$row->address.'</span></td>';
                echo    '<td><span id="'.$row->number_phone.'" class="tooltip">'.$row->number_phone.'</span></td>';
                echo    '<td>'.$row->fax.'</td>';
                echo    '<td>'.$row->site.'</td>';
                echo    '<td>'.$row->email.'</td>';
                echo    '<td>'.$row->date.'</td></tr>';
            }
    ?&gt;

    </table>
    &lt;?= $pagination;?&gt;
</div>
#3

[eluser]SaSa[/eluser]
Please help me...




Theme © iAndrew 2016 - Forum software by © MyBB