Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Arcade - Models and Controllers - Pulling Game ID from the URL
#2

[eluser]gtech[/eluser]
my advice is to read the user guide general topics on controllers,models and views.

your controller function will have a parameter say $gameid and that gets passed to the model

eg
Code:
//controller function
..
  function getgame($gameid) {
    $this->load->model('mdl_game');
    $gameinfo = $this->mdl_game->getgamedb($gameid);
    //game info will be an associative array containing the row information
    //as load view expects an associative array it should split the array into
    //variables relating to the column names in the db table
    $this->load->view('whatever',$gameinfo);
  }
..
//model function
..
  function getgamedb($gameid) {
    $result = $this->db->getWhere('games',array('gameid'=>$gameid));
    // will return array('gameid'=>5, '<column>'=>'<data>') etc.
    return $result->row_array();
  }
..
//view
&lt;?=$gameid?&gt;<br>
&lt;?=$column_name1?&gt;<br>
&lt;?=$column_name2?&gt;<br>

The URL would look somthing like
http://<CIINSTALL>/index.php/game/getgame/5
5 begin the game id.

I have not tested this code, its there to give you an idea along with reading the guide

hope it helps.


Messages In This Thread
Codeigniter Arcade - Models and Controllers - Pulling Game ID from the URL - by El Forum - 05-21-2008, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB