mngkin mas..
ne tk kc scriptnya... tlong d priksa ea mas....
tampil.php
<div id="content">
<h2 align="center">Data Pelanggan</h2>
<table width="102%" border="0" align="center" cellpadding="0" cellspacing="0" id="tabel">
<tr bgcolor="#8BB2D9">
<th width="3%" height="39">No</td>
<th width="20%">ID Pelanggan</td>
<th width="15%">Nama</td>
<th width="14%">Alamat</td>
<th width="9%">Tarif_Daya</td>
<th width="8%">Mutasi</td>
<th width="9%">Rak_Loker</td>
<th width="15%">Keterangan</td>
<th width="7%">Action</td>
</tr>
<?
include "koneksi.php";
$sql="SELECT * FROM dt_pel ORDER BY id_pel";
$tampil = mysql_query($sql);
while ( $hasil = mysql_fetch_array ($tampil)) {
$id_pel = stripslashes ($hasil['id_pel']);
$nama = stripslashes ($hasil['nama']);
$alamat = stripslashes ($hasil['alamat']);
$tarif_daya = stripslashes ($hasil['tarif_daya']);
$mutasi = stripslashes ($hasil['mutasi']);
$rak_loker = stripslashes ($hasil['rak_loker']);
$keterangan = stripslashes ($hasil['keterangan']);
{
$no++;
?>
<tr align="center">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr align="center">
<td><?=$no?>
<div align="center"></div></td>
<td><?=$id_pel?>
<div align="center"></div></td>
<td><?=$nama?>
<div align="center"></div></td>
<td><?=$alamat?>
<div align="center"></div></td>
<td><?=$tarif_daya?>
<div align="center"></div></td>
<td><?=$mutasi?>
<div align="center"></div></td>
<td><?=$rak_loker?>
<div align="center"></div></td>
<td><?=$keterangan?>
<div align="center"></div></td>
<td bgcolor="#CCCCCC"><div align="center"><a href="index.php?page=edit&id_pel=<?=$id_pel?>">Edit</a></div></td>
</tr>
<tr align="center">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<?
}}
?>
</table>
</div>
oea mas... kmrin q coba input data,, tp mncul alert "data harap dilengkapi".. pdhal q uda lengkapi semua..
np ea mas..
ni q sertain codingnya mas..
input.php
<FORM ACTION="simpan.php" METHOD="POST" NAME="input">
<table width="774" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td> </td>
<td width="589"> </td>
</tr>
<tr>
<td width="20" height="29"> </td>
<td width="165">ID Pelanggan</td>
<td><input type="text" name="id_pel" size="25" maxlength="20"></td>
</tr>
<tr>
<td height="30"> </td>
<td>Nama</td>
<td><input type="text" name="nama" size="30" maxlength="30"></td>
</tr>
<tr>
<td> </td>
<td>Alamat</td>
<td><textarea name="alamat" cols="40" rows="3"></textarea></td>
</tr>
<tr>
<td height="32"> </td>
<td>Tarif/Daya</td>
<td><select name="tarif" id="tarif" class=""><option value="450">450</option><option value="900">900</option>
<option value="1300">1300</option><option value="2200">2200</option><option value="3500">3500</option>
<option value="4400">4400</option><option value="5500">5500</option><option value="6600">6600</option></select>
/
<select name="daya" id="daya" class=""><option value="R1">R1</option><option value="R1T">R1T</option><option value="B1">B1</option>
<option value="B1T">B1T</option><option value="S1">S1</option><option value="S1T">S1T</option>
<option value="S2T">S2T</option></select>
</td>
</tr>
<tr>
<td height="28"> </td>
<td>Mutasi</td>
<td><input type="radio" name="mutasi" value="Pasang Baru"> Pasang Baru
<input type="radio" name="mutasi" value="Migrasi"> Migrasi
<input type="radio" name="mutasi" value="Tambah Daya"> Tambah Daya</td>
</tr>
<tr>
<td height="32"> </td>
<td>Rak/Loker</td>
<td><select name="Rak">
<? //Menampilkan Rak dari 1 - 5
for ($i=1; $i<=5; $i++) {
$tg = ($i<1) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select> /
<select name="loker">
<? //Menampilkan loker 1 - 400
for ($i=1; $i<=400; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select> </td>
</tr>
<tr>
<td> </td>
<td>Keterangan</td>
<td><textarea name="keterangan" cols="40" rows="3"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input type="submit" name="Tambah" value="Tambah">
<input type="reset" name="reset" value="Reset"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</FORM>
simpan.php
<?
//Cek Tombol
if ($_POST){
//Kirimkan Variabel
$id_pel = $_POST['id_pel'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$tarif_daya = $_POST['tarif']."/".$_POST['daya'];
$mutasi = $_POST['mutasi'];
$rak_loker = $_POST['rak']."/".$_POST['loker'];
$keterangan = $_POST['keterangan'];
//validasi data jika nama dan pesan kosong
if (empty($_POST['id_pel'])|| empty($_POST['nama'])|| empty($_POST['alamat'])|| empty($_POST['tarif'])|| empty($_POST['daya'])|| empty($_POST['mutasi'])|| empty($_POST['rak'])|| empty($_POST['loker'])|| empty($_POST['keterangan']))
{
?>
<script language="JavaScript">
alert('Data Harap Dilengkapi');
document.location='index.php?page=input';
</script>
<?
}
//Jika Validasi Terpenuhi
else
{
//Memanggil File Koneksi Database
include "koneksi.php";
//Masukan data ke Table dt_pel
$tambah="INSERT INTO dt_pel VALUES('$id_pel','$nama','$alamat','$tarif_daya','$mutasi','$rak_loker','$keterangan')";
$query_tambah=mysql_db_query($db,$tambah,$conn_db);
if ($query_tambah)
{
//Jika Sukses
//echo "Data telah diinput";
//echo"<meta http-equiv='refresh' content='0;url=index.php?page=tampil'>";
?>
<script language="JavaScript">
alert('Data Berhasil diinput');
document.location='index.php?page=tampil';
</script>
<?
}
else
{
//Jika Gagal
echo "Data gagal diinput, Silakan Ulangi";
}
}
}
?>
skalian editnya jga ea mas...
edit.php
<?php
include "koneksi.php";
if (isset($_GET['id_pel'])) {
$id_pel = $_GET['id_pel'];
} else {
die ("Error. No id_pel Selected! ");
}
//Tampilkan datanya
$query = "SELECT id_pel,nama,alamat,tarif_daya,mutasi,rak_loker,keterangan FROM dt_pel WHERE id_pel='$id_pel'";
$sql = mysql_query ($query);
$hasil = mysql_fetch_array ($sql);
$id_pel = $hasil['id_pel'];
$nama = $hasil['nama'];
$alamat = $hasil['alamat'];
//Memecah tarif/daya
list($tarif,$daya) = explode ("/",$hasil['tarif_daya']);
$mutasi = $hasil['mutasi'];
//Memecah rak/loker
list($rak,$loker) = explode ("/",$hasil['rak_loker']);
$keterangan = $hasil['keterangan'];
//proses edit
if (isset($_POST['Edit'])) {
$id_pel = $_POST['id_pel'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$tarif_daya = $_POST['tarif']."/".$_POST['daya'];
$mutasi = $_POST['mutasi'];
$rak_loker = $_POST['rak']."/".$_POST['loker'];
$keterangan = $_POST['keterangan'];
//update data
$query = "UPDATE dt_pel SET nama='$nama',alamat='$alamat',tarif_daya='$tarif_daya',
mutasi='$mutasi',rak_loker='$rak_loker',keterangan='$keterangan' WHERE id_pel='$id_pel'";
$sql = mysql_query ($query);
if ($sql) {
echo "<h2><font color=#8BB2D9><center>Data Pelanggan telah berhasil diedit</center></font></h2>";
} else {
echo "<h2><font color=red><center>Data Pelanggan gagal diedit</center></font></h2>";
}
}
?>
<div id="content">
<h2 align="center">Edit Data Pelanggan</h2>
<FORM ACTION="" METHOD="POST" NAME="input">
<table cellpadding="0" cellspacing="0" border="0" width="700">
<tr>
<td width="18"> </td>
<td width="132" height="24">ID Pelanggan</td>
<td width="550">:<b><?=$id_pel?>
<input type="hidden" name="nip" value="<?=$id_pel?>">
</b></td>
</tr>
<tr>
<td height="30"> </td>
<td>Nama</td>
<td><input type="text" name="nama" size="30" maxlength="30" value="<?=$nama?>"></td>
</tr>
<tr>
<td> </td>
<td>Alamat</td>
<td><textarea name="alamat" cols="40" rows="5"><?=$alamat?></textarea></td>
</tr>
<tr>
<td height="32"> </td>
<td>Tarif/Daya</td>
<td><select name="tarif" id="tarif" class=""><option value="450">450</option><option value="900">900</option>
<option value="1300">1300</option><option value="2200">2200</option><option value="3500">3500</option>
<option value="4400">4400</option><option value="5500">5500</option><option value="6600">6600</option></select>
/
<select name="daya" id="daya" class=""><option value="R1">R1</option><option value="R1T">R1T</option><option value="B1">B1</option>
<option value="B1T">B1T</option><option value="S1">S1</option><option value="S1T">S1T</option>
<option value="S2T">S2T</option></select>
</td>
</tr>
<tr>
<td> </td>
<td height="28">Mutasi</td>
<td><input type="radio" name="mutasi" value="Pasang Baru" <? echo ($mutasi==PasangBaru)?"checked":""; ?>>
Pasang Baru
<input type="radio" name="mutasi" value="Migrasi" <? echo ($mutasi==Migrasi)?"checked":""; ?>>
Migrasi
<input type="radio" name="mutasi" value="Tambah Daya" <? echo ($mutasi==TambahDaya)?"checked":""; ?>>
Tambah Daya</td>
</tr>
<tr>
<td height="32"> </td>
<td>Rak/Loker</td>
<td><select name="Rak">
<? //Menampilkan Rak dari 1 - 5
for ($i=1; $i<=5; $i++) {
$tg = ($i<1) ? "0$i" : $i;
echo "<option value='$tg'>$tg</option>";
}
?>
</select> /
<select name="loker">
<? //Menampilkan loker 1 - 400
for ($i=1; $i<=400; $i++) {
$bl = ($i<10) ? "0$i" : $i;
echo "<option value='$bl'>$bl</option>";
}
?>
</select> </td>
</tr>
<tr>
<td> </td>
<td>Keterangan</td>
<td><textarea name="keterangan" cols="40" rows="3"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input type="submit" name="Edit" value="Edit Data">
<input type="reset" name="reset" value="Reset"></td>
</tr>
</table>
</FORM>
</div>
maaf ea mas lok terlalu banyak pertanyaan.. cs mc gag mudeng q...
thanks sblumnya....