i have a table named group where i have columns like admin,editor,user,guest they are all boolean.
i want to create a group using checkbox. so in my view i got checkbox like admin,editor,user,guest and a create button. When i click the create button i want the checked options to be true in database and unchecked remains false. how can i do that?
I am new in codeigniter.
<html>
<head>
<title>Create A group</title>
</head>
<body>
<?php echo form_open('group/create_group'); ?>
<div>
<?php echo form_label("Gruop Name"); ?>
<?php
$data=array(
'name'=>'group_name',
'placeholder'=>'enter group name'
);
?>
<?php echo form_input($data); ?>
</div>
<div>
<?php $data=array(
'name'=>'role[]',
'value'=>'1',
'type'=>'checkbox'
);
?>
<?php echo form_label('Admin'); ?>
<?php echo form_checkbox($data); ?>
</div>
<div>
<?php $data=array(
'name'=>'role[]',
'value'=>'2'
);
?>
<?php echo form_label('User'); ?>
<?php echo form_checkbox($data); ?>
</div>
<div>
<?php $data=array(
'name'=>'role[]',
'value'=>'3'
);
?>
<?php echo form_label('Editor'); ?>
<?php echo form_checkbox($data); ?>
</div>
<div>
<?php $data=array(
'name'=>'role[]',
'value'=>'4'
);
?>
<?php echo form_label('Others'); ?>
<?php echo form_checkbox($data); ?>
</div>
<div>
<?php $data=array(
'type'=>'submit',
'value'=>'Create'
); ?>
<?php echo form_submit($data); ?>
</div>
<?php echo form_close(); ?>
</body>
Aucun commentaire:
Enregistrer un commentaire