[eluser]Unknown[/eluser]
Hello, I am trying to generate multiple forms in one submit. For example, I have a table with information about games on any sport, these are the fields (gameID, weekNum, gameTime, homeID, homeScore, visitorID, visitorScore). I want to use this table to generate the forms.
Inside my view I am trying to generate the forms dynamically using the above mentioned table, so the selected team can be submitted to another results table.
I am doing this in my view:
Code:
<div id="games_form">
<? foreach($games as $row) { ?>
<? echo form_open('games/submit'); ?>
<p><? echo form_radio('game_result', 'accept', FALSE);?><? echo $row->homeID ;?></p>
<p><? echo form_radio('game_result', 'accept', FALSE);?><? echo $row->visitorID ;?></p>
<? echo '<hr/>'; ?>
<? } ?>
<? echo form_submit('mysubmit', 'submit'); ?>
</div>
The problem with this approach is that I am just able to select one team from the list, instead one for every game.
This is my games_model
Code:
//retrieve all games
function get_all(){
return $this->db->get('nflp_schedule');
}
This is my games controller, I am filtering the games by week with another function.
Code:
class Games extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('games_model');
$this->load->helper('url');
$this->load->library('table');
$this->load->helper('form');
}
function index(){
$data['title'] = "Games forecast";
$data['headline'] = "Games List";
$data['include'] = 'games_list';
$data['weeks'] = $this->games_model->get_weeks();
$query_weeks = $this->games_model->get_all();
$data['games_table'] = $this->table->generate($query_weeks);
$this->load->view('template', $data);
}
function week(){
$data['games'] = $this->games_model->get_by_week($this->uri->segment(3));
$data['title'] = "Games forecast";
$data['headline'] = "Games List";
$data['include'] = "games_list";
$data['weeks'] = $this->games_model->get_weeks();
$this->load->model('games_model');
$this->load->view('template', $data);
}
}
I will appreciate any comments or help. Thanks in advanced.