i want to get the checkbox that value 1 if checked and 0 if unchecked
heres my form.php code
<?= form_open('What/yougot') ?>
<table>
<tr><td>
<input name="id" type="text">
</td></tr>
<tr><td>
<input name="method1" type="checkbox" value="valuee">
<input name="method2" type="checkbox" value="valuee">
<input name="method3" type="checkbox" value="valuee">
</td></tr>
<tr><td>
<input name="show" type="submit">
</td></tr>
</table>
<?= form_close() ?>
i DO NOT know how to put it in controller but i want something like this
public function yougot (){
if (isset($_POST['show'])) {
$data = [
'id'=>$this->model_yougot->showYougot(id)->result_array(), //to select name and id based on id
if ('method1' = 'valuee'){
'metode1' => 1 } else {
'metode1' => 0 },
if ('method2' = 'valuee'){
'metode2' => 1 } else {
'metode2' => 0 },
if ('method3' = 'valuee'){
'metode3' => 1 } else {
'metode3' => 0 },
];
}
$this->load->view('view_yougot',$data);
}
this is the model
public function showYougot($id){
return $this->db->get_where('data',['id'=>$id]);
}
and then in the view_yougot.php i want these variables
$id = $data['id'];
$name = $data['name'];
$metod1 = $data['metode1'];
$metod2 = $data['metode2'];
$metod3 = $data['metode3'];
and use them to show the value somewhere like
name = <?= $name; ?><br>
id = <?= $id; ?><br>
mehhod 1 = <?= $metod1; ?><br>
mehhod 2 = <?= $metod2; ?><br>
mehhod 3 = <?= $metod3; ?>
each $metod1 $metod2 $metod3 is showing 1 if checked or 0 if unchecked
i know im doing the select name and id wrong please help me correct it too. i have looked on google and can't find tutorials. alternatives way is okay. this is my first time please kindly teach me thank you
Aucun commentaire:
Enregistrer un commentaire