[eluser]rajneeshgobin[/eluser]
this is my first codeigniter work here is the situation
i wish something like this but with many more check boxes about 100 probably,
the senario ls like this
there will be many users in a system,
each user profile will have these kind of questions
for example
Hobby :
tenis []
badminton[]
footbal[]
carrom[]
programming language :
perl[]
python[]
cobol[]
as3[]
favorit biscuit :
bakers[]
subana[]
ect[]
ect ect
these checkbox need to reflect for diferent users.
administrator can add new category [ ie hobby , programming language]
under each category he can add more options such as football, tenis ect
he should be able to have an interface to modify the options entered by user when a user request a change
what is a good way to implement this in php mysql
here is what i was able to do so far...
view
Code:
<?php echo form_open('usersctrl/data_submit/'); ?>
<table width="485" cellspacing="0" cellpadding="0">
<tr>
<td width="85">
</td>
<td width="200" colspan="2">
</td>
</tr>
<tr>
<td>
users type:
</td>
<td>
<input name="username" value="
<?php echo set_value('username'); ?>
" type="text" />
</td>
<td>
<?php echo form_error('users data'); ?>
</td>
</tr>
<tr>
<td>
test field:
</td>
<td>
<input name="password" value="
<?php echo set_value('password'); ?>
" type="text" />
</td>
<td>
<?php echo form_error('date'); ?>
</td>
</tr>
<tr>
<td width="223">
</td>
<td>
<input name="add" type="submit" value="add" alt="add" />
</td>
</tr>
</table>
<table >
<?php foreach ($query_platform as $row): { ?>
<tr>
<th><?php echo $row['categoryName'];?></th>
</tr>
<?php foreach ($query_option as $row_options): { if($row_options['subcategory_id']==$row['id']) {?>
<tr>
<td><?php echo $row_options['subcategory_name'];?></td>
<td><input type="checkbox" name="" value=""></input></td>
</tr>
<?php }} ?>
<?php endforeach; ?>
<?php } ?>
<?php endforeach; ?>
</table>
<?php echo form_close(); ?>
category model
Code:
function allCategory()
{
$this->db->select('id');
$this->db->select('CategoryName');
$this->db->from('categorytable');
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row) {
$data_room_type[] = $row;
}
}
return $data;
}
subcategorymodel
Code:
function allOptions()
{
$this->db->select('id');
$this->db->select('subcategory_name');
$this->db->select('subcategory_id');
$this->db->from('subcategory');
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row) {
$data[] = $row;
}
}
return $data;
}
user controller
Code:
public function add_users()
{
//$data['user_id'] = $this->users_model->get_user_id_from_username($this->session->userdata('username'));
foreach ($this->users_model->get_user_id_from_username($this->session->userdata('username')) as $row)
{
$config = array('userID' => $row->id);
} //$config = array('userID' => $this->session->userdata('username'));
$this->load->library('acl', $config);
$this->load->model('category_model');
$this->load->model('subcategory_model');
$data['query_platform'] = $this->platform_model->allCategory();
$data['query_option'] = $this->options_model->allOptions();
$this->load->view("site_header");
$this->load->view("site_nav");
$this->load->view("admin/users/users_add",$data);
$this->load->view("site_footer");
}
below is a screenshot of what i got so far,
now i wish to be able to save these sub category options to database when we click save user here. how can i save all these data and is the above method good so far?