Welcome Guest, Not a member yet? Register   Sign In
Problem with counter in table
#1

I need to insert an auto incrementing number in a table.

The model is:

PHP Code:
public function players($limit$offset) {
                  
$player $this->load->database('player'TRUE);
                  
$player->select('p.name, p.job, p.level, pindex.empire, p.exp');
                  
$player->from('player AS p');
                  
$player->join('player_index AS pindex''p.account_id = pindex.id''INNER');
                  
$player->not_like('p.name','[');
                  
$player->order_by('exp DESC, level DESC'); 
                  
$player->limit($limit$offset);
                  
$query $player->get();
                  
$query_player $query->result_array();
                  return 
$query_player;
        } 

The controller is:
PHP Code:
public function players($offset 0) {
        
$offset = ($this->uri->segment(3) != '' $this->uri->segment(3): 1);
        
$config = array();
        
$config["base_url"] = base_url() . "index.php/rank/players";
        
$total_row $this->ranks->record_count('player''player');
        
$config["total_rows"] = $total_row;
        
$config["per_page"] = 25;
        
$offset = (($offset-1) * $config["per_page"])+1;        
        
$config['use_page_numbers'] = TRUE;
        
$this->pagination->initialize($config);
        
$str_links $this->pagination->create_links();
        
$data["links"] = explode(' ',$str_links );
        
$data['variable'] = $this->ranks->players($config["per_page"], $offset);
        
$this->smarty->view('rank_player.tpl'$data);
    } 

The template is:

PHP Code:
{foreach $variable as $data}
                    <
tr>
                        <
td>{$data.name}</td>
<
td>{$data.job}</td>
                        <
td>{$data.level}</td>
<
td>{$data.empire}</td>
                        <
td>{$data.exp}</td>
                    </
tr>
                {/foreach} 

The template is in smarty template.

How can I insert an auto incrementing number that continues to increase with changing page? And it can set within that foreach?


Sorry for the inconvenience, but I just can not figure out how. Thanks for the answers.
Reply


Messages In This Thread
Problem with counter in table - by StratoKyke - 05-05-2015, 06:30 AM
RE: Problem with counter in table - by StratoKyke - 05-07-2015, 04:45 AM
RE: Problem with counter in table - by StratoKyke - 05-07-2015, 07:20 AM
RE: Problem with counter in table - by StratoKyke - 05-07-2015, 10:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB