Semoga bisa dijawab yah ,,,,
Bagaimana cara membuat checked checkbox dari array ... ? scrip dibawah sih udah bisa nampilin checkednya .... Dari data yang ada di database ada 4 jawaban (2 5 7 9) tetapi ketika di masukan ke dalam checkbox yang tercentang adalah data (1 2 3 4). . jadi gak sesuai dengan yang ada di database . Solusinya gimana yah Mohon bantuannya nya Om .....
<title>LEMBAR REQUEST</title>
<style type="text/css">
<!--
.style4 {font-weight: bold}
-->
</style>
<?php
include "config2.php";
include "dbfunctions.php";
include "authentication.php";
//$query = "SELECT lokasi from info_pro where no_urut='$no_urut'";
$query = "SELECT request.*, date_format(req_date,'%d-%m-%Y')as req_date, date_format(schd_date,'%d-%m-%Y')as schd_date, customer.perusahaan, jasa.jasa, divisi.bagian FROM request, customer, jasa, divisi WHERE request.customer=customer.kode_pt AND request.tugas=jasa.kode_jasa AND request.from=divisi.kode_bag AND request.no_urut='$no_urut' ORDER BY no_urut DESC LIMIT 0, 1";
$query1 = "SELECT * FROM informasi ORDER BY kode_info";
$query2 = "SELECT * FROM ternal ORDER BY no";
$query3 = "SELECT * FROM divisi ORDER BY kode_bag";
opendb();
$hasil = querydb($query);
$hasil1 = querydb($query1);
$hasil2 = querydb($query2);
$hasil3 = querydb($query3);
closedb();
$kode_info = array();
$nama_info = array();
$no = array();
$kondisi = array();
$kode_bagian = array();
$bagian = array();
$inisial = array();
$email = array();
while ($data1 = mysql_fetch_array($hasil1))
{
$kode_info[] = $data1["kode_info"];
$nama_info[] = $data1["nama_info"];
}
$count1 = count($kode_info);
while ($data2 = mysql_fetch_array($hasil2))
{
$no[] = $data2["no"];
$kondisi[] = $data2["kondisi"];
}
$count2 = count($no);
while ($data3 = mysql_fetch_array($hasil3))
{
$kode_bag[] = $data3['kode_bag'];
$inisial[] = $data3['inisial'];
$bagian[] = $data3['bagian'];
$email[] = $data3['email'];
}
$count3 = count($kode_bag);
while($data = mysql_fetch_array($hasil))
{
$no_urut = $data["no_urut"];
$from = $data["from"];
$kontrak = $data["kontrak"];
$req_date = $data["req_date"];
$schd_date = $data["schd_date"];
$tugas = $data["tugas"];
$customer = $data["customer"];
$pic = $data["pic"];
$detail_kerja = $data["detail_kerja"];
$personal = $data["personal"];
$status_fr = $data["status_fr"];
$fr = $data["fr"];
$tujuan = $data["tujuan"];
$distribusi_req = $data["distribusi_req"];
$info_cust = $data["info_cust"];
$info_from = $data["info_from"];
$info_unit = $data["info_unit"];
$perusahaan = $data["perusahaan"];
$jasa = $data["jasa"];
$bagian = $data["bagian"];
?>
<title>FORM REQUEST</title><body>
<table width='100%' border='1'>
<tr>
<td width='10%' height='123'><img src='bkubku.PNG' width='106' height='103'></td>
<td width='80%' align='center'><strong><font size='2'>PT. BINTANG KOMUNIKASI UTAMA</strong><br>Jl. Jengki Raya no.43 Kebon Pala Jakarta Timur 13650<br>Telp.(021)80878128/29 Fax.(021)80878130<br>Website: http://www.bintangku.com</td>
<td width='10%'> </td>
</tr>
</table>
<br />
<table width='100%' border='0'>
<tr>
<td width='10%'> </td>
<td width='80%'><div align='center'><strong><font size='2'>FORM REQUEST</strong></div></td>
<td width='10%'> </td>
</tr>
<tr>
<td> </td>
<td><div align='center'><strong><font size='2'><?php echo $fr; ?></strong></div></td>
<td> </td>
</tr>
</table>
<table width='100%' border='0'>
<tr>
<td width='15%'><font size='2'>Dari</td>
<td width='69%'><font size='2'>: <?php echo $bagian; ?></td>
<td width='16%'><font size='2'>Tanggal : <?php echo $req_date; ?></td>
</tr>
<tr>
<td width='15%'><font size='2'>Referensi Kontrak</td>
<td><font size='2'>: <?php echo $kontrak ?> </td>
<td><font size='2'> </td>
</tr>
<tr>
<td colspan='3' bgcolor='#0066CC'><span class='style4'><font size='2'>Distribusi ke Unit :</span><span class='style4'></span></td>
</tr>
</table>
<?
$distribusi_req = count($distribusi_req);
$distribusi = explode(",", $ditribusi_req);
// kode yang haru muncul 2579
echo $distribusi[0]; //Direktur Utama
echo $distribusi[1]; //Customer Service
echo $distribusi[2]; //Finance
echo $distribusi[3]; //Workshop
echo $distribusi[4]; //IT
echo $distribusi[5]; //HR
echo $distribusi[6]; //Warehouse
echo $distribusi[7]; //Marketing
echo $distribusi[8]; //Operasional
?>
<table width='100%' border='0'>
<tr>
<td><input type='checkbox' <? echo ($distribusi['0'])? $distsibusi_req['0'] : "checked" ?>/>(1).Direktur Utama</td>
<td><input type='checkbox' <? echo ($distribusi['2'])? $distsibusi_req['2'] : "checked" ?>/>(3).Finance</td>
<td><input type='checkbox' <? echo ($distribusi['3'])? $distsibusi_req['3'] : "checked" ?>/>(4).Workshop</td>
</tr>
<tr>
<td><input type='checkbox' <? echo ($distribusi['5'])? $distsibusi_req['5'] : "checked" ?>/>(6).Managemnet Rep</td>
<td><input type='checkbox' <? echo ($distribusi['4'])? $distsibusi_req['4'] : "checked" ?>/>(5).Infromation & tech </td>
<td><input type='checkbox' <? echo ($distribusi['6'])? $distsibusi_req['6'] : "checked" ?>/>(7).Warehouse </td>
</tr>
<tr>
<td><input type='checkbox' <? echo ($distribusi['1'])? $distsibusi_req['1'] : "checked" ?>/>(2).Customer Service</td>
<td><input type='checkbox' <? echo ($distribusi['8'])? $distsibusi_req['8'] : "checked" ?>/>(9).Opertional & Tech Supp </td>
<td><input type='checkbox' <? echo ($distribusi['7'])? $distsibusi_req['7'] : "checked" ?>/>(8).Lainnya</td>
</tr>
<tr>
<td colspan='3' bgcolor='#0066CC'><span class='style4'>Infromasi Pelanggan :</span><span class='style4'></span></td>
</tr>
</table>
<?
//hubungan ke pelanggan (eksternal / internal)
$ternal = explode(",", $info_cust);
$ternal[0]; //eksternal
$ternal[1]; //internal
for ($i=0;$i<$count2;$i++)
{
$isi .="<input name='ternal[]' type='checkbox'>$kondisi[$i] </div>";
}
$isi .= "<table width='100%' border='0'>
<tr>
<td width='14%'><font size='2'>Tujuan Penugasan</td>
<td width='86%'><font size='2'>: $jasa</td>
</tr>
<tr>
<td width='14%'><font size='2'>Nama Pelanggan</td>
<td width='86%'><font size='2'>: $perusahaan</td>
</tr>
<tr>
<td width='14%'><font size='2'>Nama Kontak</td>
<td width='86%'><font size='2'>: $pic</td>
</tr>
</table>";
//Media Informasi yang dipakai
$isi .= "<tr><td>Informasi Diterima Melalui</td>";
$isi .= " <td>:</td>";
$infodari = explode(",", $info_from);
$infodari[0]; //Faximile
$infodari[1]; //Email
$infodari[2]; //Telepon
$infodari[3]; //SMS
$infodari[4]; //Lainnya
for ($a=0; $a<$info; $a++);
for ($i=0;$i<$count1;$i++)
{
$isi .=" <input name='informasi[]' type='checkbox'>$nama_info[$i] </div>";
}
$isi .= "<table width='100%' border='0'>
<tr>
<td colspan='3' bgcolor='#0066CC'><span class='style4'><font size='2'>Jenis Pekerjaan :</span><span class='style4'></span></td>
</tr>
</table>";
$isi .= "<table width='100%' border='0'>
<tr>
<td width='20%'><input type='checkbox' name='divisi' value='Operasional' /><font size='2'>OT</td>
<td width='20%'><input type='checkbox' name='divisi' value='IT' /><font size='2'>IT</td>
<td width='20%'><input type='checkbox' name='divisi' value='Workshop' /><font size='2'>CS</td>
<td width='20%'><input type='checkbox' name='divisi' value='Finance' /><font size='2'>Workshop</td>
<td width='20%'><input type='checkbox' name='divisi' value='Warehoose' /><font size='2'>Warehouse</td>
</tr>
<tr>
<td><font size='2'>1. </td>
<td><font size='2'>1. </td>
<td><font size='2'>1. </td>
<td><font size='2'>1. </td>
<td><font size='2'>1. </td>
</tr>
<tr>
<td><font size='2'>2. </td>
<td><font size='2'>2. </td>
<td><font size='2'>2. </td>
<td><font size='2'>2. </td>
<td><font size='2'>2. </td>
</tr>
<tr>
<td><font size='2'>3. </td>
<td><font size='2'>3. </td>
<td><font size='2'>3. </td>
<td><font size='2'>3. </td>
<td><font size='2'>3. </td>
</tr>
<tr>
<td><font size='2'>4. </td>
<td><font size='2'>4. </td>
<td><font size='2'>4. </td>
<td><font size='2'>4. </td>
<td><font size='2'>4. </td>
</tr>
<tr>
<td><font size='2'>5. </td>
<td><font size='2'>5. </td>
<td><font size='2'>5. </td>
<td><font size='2'>5. </td>
<td><font size='2'>5. </td>
</tr>
</table>";
$isi .= "<table width='100%' border='0'>
<tr>
<td bgcolor='0066CC'><strong><font size='2'>Detail Pekerjaan :</storng></td>
</tr>
</table>";
$isi .= "<table width='100%' border='1'>
<tr>
<td valign='top' height='200'><font size='2'>$detail_kerja</td>
</tr>
</table>";
if ($status_fr == "Proceed")
{
$isi .="<align='right'><input type='button' value='TAMBAH SURAT TUGAS' onClick=\"window.open('st.php?id=Open&fr=$fr')\">";
$isi .="<input type='button' value='CETAK KE PRINTER' onClick=\"window.print()\">";
$isi .="<INPUT TYPE=\"button\" VALUE=\"E-mall\" onClick=\"location.href='mailto:name@domain.net?cc=name@domain.net'\">";
}
$isi .= "</table>";
if ($SES_GOL>1 and $status_fr == 'Open'){
$isi .= "<align='right'><input type='button' value='BUAT SURAT TUGAS' onClick=\"window.open('st.php?id=$status_fr&fr=$fr')\">";
$isi .="<input type='button' value='CETAK KE PRINTER' onClick=\"window.print()\">";
$isi .="<INPUT TYPE=\"button\" VALUE=\"E-mall\" onClick=\"location.href='mailto:name@domain.net?cc=name@domain.net'\">";
}
else {
$isi .= "";
}
}
echo $isi;
?>