<?php
echo "Tanggal Lahir:";
//membuat select tanggal
?>
<select name="tanggal">
<?php for($i=1;$i<32;$i++){?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php }?>
</select>
<!-- membuat select bulan -->
<select name="bulan">
<?php for($i=1;$i<13;$i++){?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php }?>
</select>
<!-- membuat select tahun -->
<select name="tahun">
<?php for($i=((int)date('Y')-30);$i<(int)date('Y');$i++){?>
<option value="<?=$i;?>"><?=$i;?></option>
<?php }?>
</select>
kode untuk menyimpan data:<?php
//sbelumnya inget melakukan koneksi ke database
$tanggalLahir = "{$_POST['tahun']}-{$_POST['bulan']}-{$_POST['tanggal']}";
$sql = "insert into table (tanggal_lahir) values ('$tanggalLahir')";
mysql_query($sql);
?>
<style type="text/css">
.main {
margin-top: 5px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>
<?php
$sql = "select * from debitur order by Kode_Debitur desc";
$proses = mysql_query($sql);
$record = mysql_fetch_array($proses)
?>
<div class="main">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th align="left" scope="col"><font face="Tahoma, Geneva, sans-serif" color="#000000" size="3">TAMBAH DATA DEBITUR</font></th>
</tr>
<tr>
<td><hr /></td>
</tr>
<tr>
<td>
<form id="form1" name="form1" method="post" action="index.php?go=Debitur_Simpan">
<table width="423" border="0" align="left">
<tr>
<td width="147" align="left" valign="middle">Kode Debitur</td>
<td width="10" align="left" valign="middle">:</td>
<td width="254" align="left" valign="middle"><input name="kddebiturtxt" type="text" id="kddebiturtxt" value="<?php echo "DB-"; echo $record['Id_Debitur']+1?>" size="7" maxlength="50" readonly="readonly" /></td>
</tr>
<tr>
<td align="left" valign="middle">Nama Debitur</td>
<td align="left" valign="middle">:</td>
<td align="left" valign="top"><input name="nmdebiturtxt" type="text" id="nmdebiturtxt" size="35" maxlength="35" /></td>
</tr>
<tr>
<td align="left" valign="middle">Kode File</td>
<td align="left" valign="middle">:</td>
<td align="left" valign="top">
<input type="checkbox" name="kdberkasalst" value="Asli">Asli <br/>
<input type="checkbox" name="kdberkasklst" value="Kerja">Kerja
</tr>
<tr>
<td align="left" valign="top">Kode Produk</td>
<td align="left" valign="top">:</td>
<td>
<?php
//sql
$sql2 = "select Kode_Berkas, Nama_Berkas from berkas where Jenis_Berkas = 'Produk'";
$proses2 = mysql_query($sql2);
//for each record returned
while ($record2 = mysql_fetch_array($proses2)){
//chk sebagai array
?>
<input type="checkbox" name="chk" value="<?php echo $record2[Kode_Berkas]; ?>" /> <?php echo $record2[Nama_Berkas]; ?> <br/>
<?php
}
?></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
<td align="left" valign="top"><label>
<input type="submit" name="Submit" value="Simpan" />
</label>
</span></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
for($i=0; $i<count($chk); $i++){
echo $chk[$i]." ";}
$sql = "INSERT INTO debitur(Kode_Debitur,Nama_Debitur,Kode_Berkas_Asli,Kode_Berkas_Kerja,Kode_Produk)
VALUES ('$_POST[kddebiturtxt]','$_POST[nmdebiturtxt]','$_POST[kdberkasalst]','$_POST[kdberkasklst]','$_POST[chk]')";
$proses = mysql_query($sql);
if ($proses) {
header("location:index.php?go=Debitur");
} else { echo "DEBITUR TIDAK DAPAT DI SIMPAN ATAU DEBITUR SUDAH ADA";
}
?>