Page 1

PERTANYAAN A. Buatlah table dan program untuk memasukkan data nilai mahasiswa dengan tampilan seperti tampak pada gambar di bawah ini.

B.

Diketahui Database Karyawan sebagai berikut:

Tabel: bagian Kode_bagian ACT MKT HRD LGT

Nama_bagian Accounting Marketing Human Resource Development Logistic


Tabel: Lembur ID nik 1 10005 2 10005 10005 3 4 10005 5 10005 6 10010 7 10011 10012 8 9 10013 10 10014 11 10015 12 10016 13 10017

tanggal_lembur 2011-07-11 2011-07-12 2011-07-13 2011-07-14 2011-07-15 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17

Tabel: Karyawan nik nama 10001 Aan Nurhasanah 10002 Aas Asmawati 10003 Aliyah Hildazurny 10004 Fikri Rusliansyah 10005 Haswati 10006 Heri Maulana 10007 Jaka Taruna 10008 Martono 10009 Maryam Kurniawati Octavian 10010 Hikmawan 10011 Panji Dinur Cahyo 10012 Rindra Permana 10013 Rivo Putra 10014 Rr Nur Assifaa 10015 Said Farouk 10016 Septie Puspita 10017 Sumarni 10018 Triya Kuryasih 10019 Zunani 10020 Mutia

Jumlah_jam_lembur 4 4 2 4 2 3 5 5 5 5 5 5 5

tempat_lahir Jakarta Semarang Surabaya Bandung Jakarta Semarang Surabaya Bandung Jakarta

tanggal_lahir 1980-11-25 1974-05-20 1990-12-20 1988-04-18 1988-09-09 1989-07-30 1994-05-21 1980-11-11 1980-11-25

kode_bagian ACT MKT HRD MKT MKT MKT MKT MKT MKT

jabatan gaji Manager 10000000 Staff 3500000 Supervisor 5500000 Manager 9800000 Staff 1500000 Staff 1600000 Staff 1700000 Staff 1800000 Staff 1900000

Semarang Surabaya Bandung Jakarta Semarang Surabaya Bandung Jakarta Semarang Surabaya Bandung

1970-06-21 1980-11-01 1980-11-02 1980-11-03 1980-11-04 1980-11-05 1980-11-06 1980-11-07 1980-11-08 1980-11-09 1980-11-10

MKT MKT ACT ACT ACT ACT HRD HRD LGT LGT LGT

Staff Staff Staff Staff Staff Staff Staff Staff Supervisor Staff Staff

2000000 2100000 2200000 2300000 2400000 2500000 2600000 2700000 4500000 2100000 1350000


Pertanyaan: 1. Buatlah program php untuk menampilkan data sebagai berikut, yang hasilnya di printscreen dan dan source codenya disertakan dalam lembar jawaban. a. Menampilkan seluruh data karyawan. b. Menampilkan data karyawan yang tempat lahirnya di Semarang c. Menampilkan data karyawan bagian Marketing d. Menampilkan data karyawan yang gajinya lebih kecil dari 5 juta. 3. Buatlan program php menggunakan relasi antara tabel karyawan dan tabel bagian untuk menampilkan data seperti tampak pada gambar di bawah ini:

NIK Nama Karyawan 10001 Aan Nurhasanah 10002 Aas Asmawati

Jabatan Manager Staff

10003 10004 10005 10006 10007 10008 10009

Supervisor Manager Staff Staff Staff Staff Staff

5500000 9800000 1500000 1600000 1700000 1800000 1900000

Staff Staff Staff Staff Staff Staff

2000000 2100000 2200000 2300000 2400000 2500000

Staff

2600000

Staff Supervisor Staff Staff

2700000 4500000 2100000 1350000

10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020

Bagian Accounting Marketing Human Resource Aliyah Hildazurny Development Fikri Rusliansyah Marketing Haswati Marketing Heri Maulana Marketing Jaka Taruna Marketing Martono Marketing Maryam Kurniawati Marketing Octavian Hikmawan Marketing Panji Dinur Cahyo Marketing Rindra Permana Accounting Rivo Putra Accounting Rr Nur Assifaa Accounting Said Farouk Accounting Human Resource Septie Puspita Development Human Resource Sumarni Development Triya Kuryasih Logistic Zunani Logistic Mutia Logistic

Gaji 10000000 3500000


Buatlah program untuk menampilkan data lembur karyawan dengan output seperti tampak pada tabel di bawah ini.

Nama Karyawan ID 1 2 3 4 5 6 7 8 9 10 11 12 13

NIK 10005 10005 10005 10005 10005 10010 10011 10012 10013 10014 10015 10016 10017

Haswati Haswati Haswati Haswati Haswati Octavian Hikmawan Panji Dinur Cahyo Rindra Permana Rivo Putra Rr Nur Assifaa Said Farouk Septie Puspita Sumarni

Tanggal Lembur 2011-07-11 2011-07-12 2011-07-13 2011-07-14 2011-07-15 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17 2011-07-17

JAWABAN SOAL A Desain Struktur database db_mahasiswa, tabel tb_inputmahasiswa

Listing Program koneksi.php <?php $host $user $pass $db

= "localhost"; = "root"; = ""; = "db_mahasiswa";

Jam Lembur 4 4 2 4 2 3 5 5 5 5 5 5 5


$koneksi = mysql_connect ($host, $user, $pass) or die (mysql_error()); mysql_select_db($db, $koneksi) or die (mysql_error()); ?>

Tampilan mahasiswa_input.php

Listing Program mahasiswa_input.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>input data</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style> <h2> <font face="Cambria"color="#FF0000">INPUT DATA NILAI MAHASISWA</font> </h2> <form id="form1" name="form1" method="Post" action="mahasiswa_insert.php"> <table width="800" border="0" cellspasing="0" cellpadding="1"> <tr> <td><h4>NIM</h4></td> <td>:</td> <td><input type="text" name=nim value="" ></td> </tr> <tr> <td><h4>Nama Mahasiswa</h4></td> <td>:</td> <td><input type="text" name=namamahasiswa value="" ></td> </tr> <tr> <td><h4>Jurusan</h4></td> <td>:</td> <td><input type="radio" name="jurusan" value="MI" checked="checked" />Manajemen Informatika <input type="radio" name="jurusan" value="TK" checked="checked" />Teknik Komputer <input type="radio" name="jurusan" value="SI" checked="checked" />Sistem Informasi </tr> <tr> <td><h4>Nilai Matakuliah Database</h4></td> <td>:</td> <td><input type="text" name=nilai_db value="" ></td> </tr> <tr>


<td><h4>Nilai Matakuliah PHP</h4></td> <td>:</td> <td><input type="text" name=nilai_php value="" ></td> </tr> <tr> <td><h4>Nilai Matakuliah Java</h4></td> <td>:</td> <td><input type="text" name=nilai_java value="" ></td> </tr> </table> <input type="submit" name="input" value="Simpan"> <body> </body> </html> Tampilan mahasiswa_insert.php

Listing Program mahasiswa_insert.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Output</title> </head> <style type="text/css"> <!-body { background-image: url(pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style> <body> <?php include('Connections/koneksi.php'); $nim = $_POST['nim'];


$namamahasiswa $jurusan $nilai_db $nilai_php $nilai_java

= $_POST["namamahasiswa"]; = $_POST["jurusan"]; = $_POST["nilai_db"]; = $_POST["nilai_php"]; = $_POST["nilai_java"];

$query = mysql_query ("insert into tb_inputmahasiswa values ('$nim','$namamahasiswa','$jurusan','$nilai_db','$nilai_php','$nilai_java')", $koneksi) or die (mysql_error()); ?> <a href="mahasiswa_index.php">DATA SUDAH MASUK</a> </body> </html> Tampilan mahasiswa_index.php

Listing Program mahasiswa_index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; }


--> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select*from tb_inputmahasiswa order by nim", $koneksi) or die (mysql_error()); echo "<center><h2>DAFTAR NILAI MAHASISWA</h2></center>"; echo "<a href='mahasiswa_input.php'>Input Nilai</a>"; echo "<br></br>"; echo "<table width='100%' border=1 cellpadding=0 cellspacing=0 align=left> <tr> <th>NIM</th> <th>Nama Mahasiswa</th> <th>Jurusan</th> <th>Nilai Matakuliah Database</th> <th>Nilai Matakuliah PHP</th> <th>Nilai Matakuliah Java</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> <td>$row[5]</td> </tr>"; } echo "</table>"; ?> </body> </html>


JAWABAN SOAL B Desain Struktur database db_karyawan

Desain Diagram database db_karyawan


Desain Struktur tabel tb_bagian

Desain Struktur tabel tb_lembur


Desain Struktur tabel tb_karyawan

Isi tabel tb_bagian

Isi tabel tb_lembur


Isi tabel tb_karyawan

Listing Program koneksi.php <?php $host = "localhost"; $user = "root"; $pass = ""; $db = "db_karyawan"; $koneksi = mysql_connect ($host, $user, $pass) or die (mysql_error()); mysql_select_db($db, $koneksi) or die (mysql_error());


?>

JAWABAN SOAL B NO. 1 Tampilan karyawan_browse1A.php

Listing Program karyawan_browse1A.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px;


} --> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select*from tb_karyawan order by nik", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN</h2></center>"; echo "<table width='100%' border=1 cellpadding=0 cellspacing=0 align=left> <tr> <th>NIK</th> <th>Nama</th> <th>Tempat Lahir</th> <th>Tanggal Lahir</th> <th>Kode Bagian</th> <th>Jabatan</th> <th>Gaji</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> <td>$row[5]</td> <td>$row[6]</td> </tr>"; } echo "</table>"; ?> </body> </html> Tampilan karyawan_browse1B.php


Listing Program karyawan_browse1B.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select*from tb_karyawan where tempat_lahir ='Semarang' order by nik", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN</h2></center>"; echo "<table width='100%' border=1 cellpadding=0 cellspacing=0 align=left> <tr> <th>NIK</th> <th>Nama</th> <th>Tempat Lahir</th> <th>Tanggal Lahir</th>


<th>Kode Bagian</th> <th>Jabatan</th> <th>Gaji</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> <td>$row[5]</td> <td>$row[6]</td> </tr>"; } echo "</table>"; ?> </body> </html> Tampilan karyawan_browse1C.php

Listing Program karyawan_browse1C.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head>


<style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select Nik, Nama, Tempat_Lahir, Tanggal_Lahir, Nama_Bagian, Jabatan, Gaji from tb_karyawan join tb_bagian on tb_bagian.kode_bagian=tb_karyawan.kode_bagian where tb_karyawan.Kode_Bagian='MKT'", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN BAGIAN MARKETING</h2></center>"; echo "<table width='100%' border=1 cellpadding=0 cellspacing=0 align=left> <tr> <th>NIK</th> <th>Nama</th> <th>Tempat Lahir</th> <th>Tanggal Lahir</th> <th>Nama Bagian</th> <th>Jabatan</th> <th>Gaji</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> <td>$row[5]</td> <td>$row[6]</td>


</tr>"; } echo "</table>"; ?> </body> </html> Tampilan karyawan_browse1D.php

Listing Program karyawan_browse1D.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; }


--> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select*from tb_karyawan where gaji <='5000000' order by nik", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN GAJI DI BAWAH 5.000.000</h2></center>"; echo "<table width='100%' border=1 cellpadding=0 cellspacing=0 align=left> <tr> <th>NIK</th> <th>Nama</th> <th>Tempat Lahir</th> <th>Tanggal Lahir</th> <th>Kode Bagian</th> <th>Jabatan</th> <th>Gaji</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> <td>$row[5]</td> <td>$row[6]</td> </tr>"; } echo "</table>"; ?> </body> </html>

JAWABAN SOAL B NO. 2


Tampilan karyawan_browse2A.php

Listing Program karyawan_browse2A.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style>


<body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select Nik, Nama, Nama_Bagian, Jabatan, Gaji from tb_karyawan join tb_bagian on tb_bagian.kode_bagian=tb_karyawan.kode_bagian order by nik", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN</h2></center>"; echo "<table width='65%' border=1 cellpadding=0 cellspacing=0 align=center> <tr> <th>NIK</th> <th>Nama Karyawan</th> <th>Bagian</th> <th>Jabatan</th> <th>Gaji</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> </tr>"; } echo "</table>"; ?> </body> </html> Tampilan karyawan_browse2B.php


Listing Program karyawan_browse2B.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <style type="text/css"> <!-body { background-image: url(images/pink.jpg); margin-left: 2px; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; } --> </style> <body> <?php include('Connections/koneksi.php'); $query = mysql_query ("select ID, tb_karyawan.Nik, Nama, Tgl_lembur, jumlah_jam_lembur


from tb_karyawan join tb_lembur on tb_lembur.nik=tb_karyawan.nik order by id", $koneksi) or die (mysql_error()); echo "<center><h2>DATA KARYAWAN</h2></center>"; echo "<table width='65%' border=1 cellpadding=0 cellspacing=0 align=center> <tr> <th>ID</th> <th>NIK</th> <th>Nama Karyawan</th> <th>Tanggal Lembur</th> <th>Jam Lembur</th> </tr>" ; while ($row = mysql_fetch_array($query)) { echo " <tr> <td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3]</td> <td>$row[4]</td> </tr>"; } echo "</table>"; ?> </body> </html>


php  

php listing program

Advertisement
Read more
Read more
Similar to
Popular now
Just for you