Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //== view.php
- <html>
- <head>
- <title>Tampil Data Mahasiswa Baru</title>
- <script language="JavaScript">
- function konfirmasi(kode) {
- tanya = confirm('Anda yakin ingin menghapus data mahasiswa ini ?');
- if (tanya == true) return true;
- else return false;
- }
- </script>
- </head>
- <body>
- <body bgcolor="chartreuse">
- <H3><center>DATA MAHASISWA</center></H3>
- <table border='1' align='center' cellpadding='2' cellspacing='0'>
- <tr bgcolor='Lightgreen'>
- <th>KODE</th>
- <th>NISN</th>
- <th>Nama Mahasiswa</th>
- <th>Tanggal Lahir</th>
- <th>Tempat Lahir</th>
- <th>Jenis Kelamin</th>
- <th>Kewarganegaraan</th>
- <th>Agama</th>
- <th>Status</th>
- <th>Alamat Rumah </th>
- <th>Alamat Semarang</th>
- <th>Telepon</th>
- <th>Asal Sekolah</th>
- <th>Jenis Ijazah</th>
- <th>Status Ijazah</th>
- <th>Jurusan Ijazah</th>
- <th>Tahun Ijazah</th>
- <th>Jurusan Pilihan</th>
- <th>Status Mahasiswa</th>
- <th>Pilihan Kuliah</th>
- <th>Nama Ayah</th>
- <th>Nama Ibu</th>
- <th>Alamat</th>
- <th>Pendidikan Ayah</th>
- <th>Pendidikan Ibu</th>
- <th>Pekerjaan Ayah</th>
- <th>Pekerjaan Ibu</th>
- <th colspan=2>AKSI</th>
- </tr>
- <?php
- include "koneksi.php";
- $koneksi=mysql_connect("localhost","root","");
- $perintah_sql = "SELECT * FROM admin WHERE 1";
- mysql_select_db("ta", $koneksi) or die("Gagal memilih database!");
- $hasil_query = mysql_query($perintah_sql, $koneksi) or die ("Gagal memproses query!");
- $jumlah_data = mysql_num_rows($hasil_query);
- while ($row=mysql_fetch_row($hasil_query))
- {
- echo "<tr>";
- for($i=0;$i<27;$i++)
- echo "<td>{$row[$i]}</td>";
- echo "<td><a href='edit.php?kode={$row[0]}'>Ubah</a></td>";
- echo "<td><a href='delete.php?kode={$row[0]}' onclick=\"return konfirmasi('{$row[0]}')\">Hapus</a>";
- echo "</tr>";
- }
- ?>
- </table>
- Jumlah data : <?php echo $jumlah_data;?> [<a href=add.php>Tambah Data</a>]
- </body>
- </html>
- //== edit.php
- <html>
- <head><title>Update Data Mahasiswa</title></head>
- <body bgcolor="purple">
- <?php
- include "koneksi.php";
- if(!isset($_GET['kode'])) header('location:view.php');$kode=$_GET['kode'];
- $query= "SELECT * FROM admin WHERE kode='$kode'";
- $hasil_query = mysql_query($query);
- $row= mysql_fetch_assoc($hasil_query);
- ?>
- <form method="post" action="update.php">
- <table align="center" border="1" cellpadding="5" cellspacing="0">
- <tr bgcolor="lightgreen">
- <td Colspan="3" align="center"><H3>Ubah Data Mahasiswa Baru</H3></td>
- </tr>
- <tr>
- <td>Kode</td>
- <td>:</td>
- <td>
- <input type="text" name="kode1" size="40" value="<?php echo $row['kode']; ?>" >
- <input type="hidden" name="kode" size="40" value=" <?php echo $row['kode']; ?>" >
- </td>
- </tr>
- <tr>
- <td>NISN</td>
- <td>:</td>
- <td>
- <input type="text" name="nisn" size="40" value="<?php echo $row['nisn']; ?>" >
- </td>
- </tr>
- <tr>
- <td>Nama Mahasiswa</td>
- <td>:</td>
- <td>
- <input type="text" name="nama" size="40" value="<?php echo $row['nama']; ?>" >
- </td>
- </tr>
- <tr>
- <td>Tanggal Lahir</td>
- <td>:</td>
- <td>
- <input type="text" name="tgl_lahir" size="40" value="<?php echo $row['tgl_lahir']; ?>" >
- </td>
- </tr>
- <tr>
- <td>Tempat Lahir</td>
- <td>:</td>
- <td>
- <input type="text" name="tempat" size="40" value="<?php echo $row['tempat']; ?>" >
- </td>
- </tr>
- <tr>
- <td>Kelamin</td>
- <td>:</td>
- <td>
- <select name="kelamin">
- <option></option>
- <option value="Pria" <?php if($row['kelamin']=='Pria'){ echo 'selected';} ?>>Pria</option>
- <option value="Wanita" <?php if($row['kelamin']=='Wanita'){ echo 'selected';} ?>>Wanita</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Kewarganegaraan</td>
- <td>:</td>
- <td>
- <select name="warga">
- <option></option>
- <option value="WNI" <?php if($row['warga']=='WNI'){ echo 'selected';} ?>>WNI</option>
- <option value="WNA" <?php if($row['warga']=='WNA'){ echo 'selected';} ?>>WNA</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Agama</td>
- <td>:</td>
- <td>
- <select name="agama">
- <option></option>
- <?php
- $agama=array('islam','katolik','kristen','budha','hindu','lain');
- foreach($agama as $a) echo "<option value='{$a}'".($row['agama']==$a?' selected':'').">".ucfirst($a)."</option>";
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>Status</td>
- <td>:</td>
- <td>
- <select name="status">
- <option></option>
- <option value="belum" <?php if($row['status']=='belum'){ echo 'selected';} ?>>Belum Nikah</option>
- <option value="nikah" <?php if($row['status']=='nikah'){ echo 'selected';} ?>>Nikah</option>
- </td>
- </tr>
- <tr>
- <td>Alamat Rumah</td>
- <td>:</td>
- <td>
- <input type="text" name="rumah" size="40" value="<?php echo $row['rumah']; ?>">
- </td>
- </tr>
- <tr>
- <td>Alamat Semarang</td>
- <td>:</td>
- <td>
- <input type="text" name="smg" size="40"value="<?php echo $row['smg']; ?>">
- </td>
- </tr>
- <tr>
- <td>Telepon</td>
- <td>:</td>
- <td>
- <input type="text" name="telp" size="40" value="<?php echo $row['telp']; ?>">
- </td>
- </tr>
- <tr>
- <td>Asal Sekolah</td>
- <td>:</td>
- <td>
- <input type="text" name="asal" size="40" value="<?php echo $row['asal']; ?>">
- </td>
- </tr>
- <tr>
- <td>Jenis Ijazah</td>
- <td>:</td>
- <td>
- <select name="jenis">
- <option></option>
- <?php
- $jenis=array('SMA','SMK','Ponpes','MA','lain');
- foreach($jenis as $j) echo "<option value='{$j}'".($row['jenis']==$j?' selected':'').">{$j}</option>";
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>Status Ijazah</td>
- <td>:</td>
- <td>
- <select name="statuss">
- <option></option>
- <?php
- $statuss=array('negeri','swasta','luar negeri','lain');
- foreach($statuss as $s) echo "<option value='{$s}'".($row['statuss']==$s?' selected':'').">".ucwords($s)."</option>";
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>Jurusan Ijazah</td>
- <td>:</td>
- <td>
- <select name="jurusan">
- <option></option>
- <?php
- $jurusan=array('IPA','IPS','Bahasa','Agama','Lain');
- foreach($jurusan as $j) echo "<option value='{$j}'".($row['jurusan']==$j?' selected':'').">{$j}</option>";
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>Tahun Ijazah</td>
- <td>:</td>
- <td>
- <input type="text" name="thun" size="40" value="<?php echo $row['thun']; ?>">
- </td>
- </tr>
- <tr>
- <td>Jurusan Pilihan</td>
- <td>:</td>
- <td>
- <select name="jurusan_pilihan">
- <option></option>
- <option value="teknik mesin" <?php if($row['jurusan_pilihan']=='teknik mesin'){ echo 'selected';} ?>>Teknik Mesin</option>
- <option value="Teknik kimia" <?php if($row['jurusan_pilihan']=='Teknik kimia'){ echo 'selected';} ?>>Teknik Kimia</option>
- <option value="Teknik Informatika" <?php if($row['jurusan_pilihan']=='Teknik Informatika'){ echo 'selected';} ?>>Teknik Informatika</option>
- <option value="Farmasi" <?php if($row['jurusan_pilihan']=='Farmasi'){ echo 'selected';} ?>>Farmasi</option>
- <option value="Manajemen" <?php if($row['jurusan_pilihan']=='Manajemen'){ echo 'selected';} ?>>Manajemen</option>
- <option value="Akuntansi" <?php if($row['jurusan_pilihan']=='Akuntansi'){ echo 'selected';} ?>>Akuntansi</option>
- <option value="Hukum" <?php if($row['jurusan_pilihan']=='Hukum'){ echo 'selected';} ?>>Hukum</option>
- <option value="Agribisnis" <?php if($row['jurusan_pilihan']=='Agribisnis'){ echo 'selected';} ?>>Agribisnis</option>
- <option value="PAI" <?php if($row['jurusan_pilihan']=='PAI'){ echo 'selected';} ?>>PAI</option>
- <option value="PGMI" <?php if($row['jurusan_pilihan']=='PGMI'){ echo 'selected';} ?>>PGMI</option>
- <option value="Hukum Ekonomi Syariah" <?php if($row['jurusan_pilihan']=='Hukum Ekonomi syariah'){ echo 'selected';} ?>>Hukum Ekonomi Syari'ah</option>
- <option value="Ilmu Politik" <?php if($row['jurusan_pilihan']=='Ilmu Politik'){ echo 'selected';} ?>>Ilmu Politik</option>
- <option value="Hub.internasional" <?php if($row['jurusan_pilihan']=='Hub.internasional'){ echo 'selected';} ?>>Hub. Internasional</option>
- <option value="Ekonomi Syariah" <?php if($row['jurusan_pilihan']=='Ekonomi Syariah'){ echo 'selected';} ?>>Ekonomi Syari'ah</option>
- <option value="Pend. Olahraga" <?php if($row['jurusan_pilihan']=='Pend. Olahraga'){ echo 'selected';} ?>>Pend. Olahraga</option>
- <option value="Kedokteran" <?php if($row['jurusan_pilihan']=='Kedokteran'){ echo 'selected';} ?>>Kedokteran</option></select>
- </td>
- </tr>
- <tr>
- <td>Status Mahasiswa</td>
- <td>:</td>
- <td>
- <select name="sts_mhs">
- <option></option>
- <option value="baru" <?php if($row['sts_mhs']=='baru'){ echo 'selected';} ?>>Baru</option>
- <option value="transfer" <?php if($row['sts_mhs']=='transfer'){ echo 'selected';} ?>>Transfer</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Pilihan Kuliah</td>
- <td>:</td>
- <td>
- <select name="pilih_kuliah">
- <option></option>
- <option value="reguler" <?php if($row['pilih_kuliah']=='reguler'){ echo 'selected';} ?>>Reguler</option>
- <option value="Ekstensi" <?php if($row['pilih_kuliah']=='Ekstensi'){ echo 'selected';} ?>>Ekstensi</option></select>
- </td>
- </tr>
- <tr class="genap">
- <td>Nama Ayah</td>
- <td>:</td>
- <td>
- <input type="text" name="ayah" size="40"value="<?php echo $row['ayah']; ?>">
- </td>
- </tr>
- <tr>
- <td>Nama Ibu</td>
- <td>:</td>
- <td>
- <input type="text" name="ibu" size="40"value="<?php echo $row['ibu']; ?>">
- </td>
- </tr>
- <tr>
- <td>Alamat</td>
- <td>:</td>
- <td>
- <input type="text" name="almt_ort" size="40"value="<?php echo $row['almt_ort']; ?>">
- </td>
- </tr>
- <tr>
- <td>Pendidikan Ayah</td>
- <td>:</td>
- <td>
- <select name="pdk_orta">
- <option></option>
- <option value="SD" <?php if($row['pdk_orta']=='SD'){ echo 'selected';} ?>>SD</option>
- <option value="SLTP" <?php if($row['pdk_orta']=='SLTP'){ echo 'selected';} ?>>SLTP</option>
- <option value="SLTA" <?php if($row['pdk_orta']=='SLTA'){ echo 'selected';} ?>>SLTA</option>
- <option value="Sarjana" <?php if($row['pdk_orta']=='Sarjana'){ echo 'selected';} ?>>Sarjana</option>
- <option value="Sarjana Muda" <?php if($row['pdk_orta']=='Sarjana Muda'){ echo 'selected';} ?>>Sarjana Muda</option>
- <option value="Magister" <?php if($row['pdk_orta']=='Magister'){ echo 'selected';} ?>>Magister</option>
- <option value="Profesor" <?php if($row['pdk_orta']=='Profesor'){ echo 'selected';} ?>>Profesor</option>
- <option value="Doktor" <?php if($row['pdk_orta']=='Doktor'){ echo 'selected';} ?>>Doktor</option>
- <option value="Lain" <?php if($row['pdk_orta']=='Lain'){ echo 'selected';} ?>>Lain</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Pendidikan Ibu</td>
- <td>:</td>
- <td>
- <select name="pdk_orti">
- <option></option>
- <option value="SD" <?php if($row['pdk_orti']=='SD'){ echo 'selected';} ?>>SD</option>
- <option value="SLTP" <?php if($row['pdk_orta']=='SLTP'){ echo 'selected';} ?>>SLTP</option>
- <option value="SLTA" <?php if($row['pdk_orta']=='SLTA'){ echo 'selected';} ?>>SLTA</option>
- <option value="Sarjana" <?php if($row['pdk_orta']=='Sarjana'){ echo 'selected';} ?>>Sarjana</option>
- <option value="Sarjana Muda" <?php if($row['pdk_orta']=='Sarjana Muda'){ echo 'selected';} ?>>Sarjana Muda</option>
- <option value="Magister" <?php if($row['pdk_orta']=='Magister'){ echo 'selected';} ?>>Magister</option>
- <option value="Profesor" <?php if($row['pdk_orta']=='Profesor'){ echo 'selected';} ?>>Profesor</option>
- <option value="Doktor" <?php if($row['pdk_orta']=='Doktor'){ echo 'selected';} ?>>Doktor</option>
- <option value="Lain" <?php if($row['pdk_orta']=='Lain'){ echo 'selected';} ?>>Lain</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Pekerjaan Ayah</td>
- <td>:</td>
- <td>
- <select name="pkrayah">
- <option></option>
- <option value="PNS" <?php if($row['pkrayah']=='PNS'){ echo 'selected';} ?>>PNS</option>
- <option value="TNI" <?php if($row['pkrayah']=='TNI'){ echo 'selected';} ?>>TNI</option>
- <option value="POLRI" <?php if($row['pkrayah']=='POLRI'){ echo 'selected';} ?>>POLRI</option>
- <option value="WIRASWASTA" <?php if($row['pkrayah']=='WIRASWASTA'){ echo 'selected';} ?>>WIRASWASTA</option>
- <option value="PETANI" <?php if($row['pkrayah']=='PETANI'){ echo 'selected';} ?>>PETANI</option>
- <option value="PENSIUNAN" <?php if($row['pkrayah']=='PENSIUNAN'){ echo 'selected';} ?>>PENSIUNAN</option>
- <option value="PEGAWAI SWASTA" <?php if($row['pkrayah']=='PEGAWAI SWASTA'){ echo 'selected';} ?>>PEGAWAI SWASTA</option>
- <option value="LAIN" <?php if($row['pkrayah']=='LAIN'){ echo 'selected';} ?>>LAIN</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Pekerjaan Ibu</td>
- <td>:</td>
- <td>
- <select name="pkribu">
- <option></option>
- <option value="PNS" <?php if($row['pkribu']=='PNS'){ echo 'selected';} ?>>PNS</option>
- <option value="TNI" <?php if($row['pkrayah']=='TNI'){ echo 'selected';} ?>>TNI</option>
- <option value="POLRI" <?php if($row['pkrayah']=='POLRI'){ echo 'selected';} ?>>POLRI</option>
- <option value="WIRASWASTA" <?php if($row['pkrayah']=='WIRASWASTA'){ echo 'selected';} ?>>WIRASWASTA</option>
- <option value="PETANI" <?php if($row['pkrayah']=='PETANI'){ echo 'selected';} ?>>PETANI</option>
- <option value="PENSIUNAN" <?php if($row['pkrayah']=='PENSIUNAN'){ echo 'selected';} ?>>PENSIUNAN</option>
- <option value="PEGAWAI SWASTA" <?php if($row['pkrayah']=='PEGAWAI SWASTA'){ echo 'selected';} ?>>PEGAWAI SWASTA</option>
- <option value="LAIN" <?php if($row['pkrayah']=='LAIN'){ echo 'selected';} ?>>LAIN</option>
- </select>
- </td>
- </tr>
- <tr align=center>
- <td Colspan=3>
- <table align="center" width="400" height="100" cellpadding="4" cellspacing="0">
- <tr bgcolor="deepskyblue"><td>
- <input type="submit" value="Update" name="simpan"> [<a href=view.php>Lihat Data Mahasiswa Baru</a>]
- </td></tr>
- </table>
- </form>
- </body>
- </html>
- //== update.php
- <html>
- <head>
- <title>Update Data Mahasiswa Baru</title>
- </head>
- <body background="coral">
- <?php
- include "koneksi.php";
- if (isset($_POST['simpan'])){
- $koneksi = mysql_connect ("localhost","root","");
- mysql_select_db("ta",$koneksi);
- $query = "
- UPDATE
- admin
- SET
- kode='{$_POST['kode1']}',
- nisn='{$_POST['nisn']}',
- nama='{$_POST['nama']}',
- tgl_lahir='{$_POST['tgl_lahir']}',
- tempat='{$_POST['tempat']}',
- kelamin='{$_POST['kelamin']}',
- warga='{$_POST['warga']}',
- agama='{$_POST['agama']}',
- status='{$_POST['status']}',
- rumah='{$_POST['rumah']}',
- smg='{$_POST['smg']}',
- telp='{$_POST['telp']}',
- asal='{$_POST['asal']}',
- jenis='{$_POST['jenis']}',
- statuss='{$_POST['statuss']}',
- jurusan='{$_POST['jurusan']}',
- thun='{$_POST['thun']}',
- jurusan_pilihan='{$_POST['jurusan_pilihan']}',
- sts_mhs='{$_POST['sts_mhs']}',
- pilih_kuliah='{$_POST['pilih_kuliah']}',
- ayah='{$_POST['ayah']}',
- ibu='{$_POST['ibu']}',
- almt_ort='{$_POST['almt_ort']}',
- pdk_orta='{$_POST['pdk_orta']}',
- pdk_orti='{$_POST['pdk_orti']}',
- pkrayah='{$_POST['pkrayah']}',
- pkribu='{$_POST['pkribu']}'
- WHERE
- kode='{$_POST['kode']}'
- ";
- $hasil=mysql_query($query);
- if($hasil){
- echo "Data Telah Diupdate";
- echo "<br>";
- }
- }
- ?>
- [<a href=view.php>Lihat Data Mahasiswa Baru</a>]
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement