i have a problem here to check the checkbox from database. because there is textbox inside my checkbox. My checkbox looks like this : https://jsfiddle.net/qqeh07e5/ First of all. It is okay to check the checkbox if there no textbox inside checkbox, because i saved the value of checkbox. But if there is a textbox inside the checkbox, i don't save checkbox's value, but save textbox's value. So my problem how to make the value from database know that its belong textbox A, not textbox B. Here is i've done so far.
<?php
$temp_detailEvent = $_SESSION['detail_event'];
$q = sqlsrv_query($conn,"SELECT * FROM EventDetail WHERE id_eventDetail='$temp_detailEvent'");
while($row = sqlsrv_fetch_array($q))
{
$tuj = explode(",",$row['tujuanTraining']);
<div class="col-lg-4">
<div class="form-group">
<label>Latar Belakang</label>
<div class="checkbox">
<label>';
?>
<input type="checkbox" name="tujuan[]" id="cekbox_tujuan1" <?php if(in_array("Pencapaian Kompetensi Karyawan",$tuj)) { ?> checked="checked" <?php } ?> value="Pencapaian Kompetensi Karyawan">Pencapaian Kompetensi Karyawan
<?php
echo '</label>
</div>
<div class="checkbox form-inline">
<label>
<input type="checkbox" id="cekbox_latarbelakang2" value="Mengacu pada Analisa GAP pada FPT Nomor">Mengacu Pada Analisa GAP pada FPT Nomor
</label>
<input type="text" id="textbox_latarbelakang1" name="latarbelakang[]" class="form-control input-sm" placeholder="">
</div>
<div class="checkbox form-inline">
<label>
<input type="checkbox" id="cekbox_latarbelakang3" value="">
Lain - lain
</label>
<input type="text" id="textbox_latarbelakang2" name="latarbelakang[]" class="form-control input-sm" placeholder="Lain - lain">
</div>
</div>
</div>';
}
i am just check if there is a value same in database with in_array
Hope someone can help me, thank you very much. Hv a nice day and CHEERSS!!