Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "db.inc.php";
- ?>
- <!doctype html>
- <html>
- <head> tes percobaan</head>
- <body>
- <?php
- $qry=mysql_query("select * from daftar_dosen");
- $qry1=mysql_query("select * from mata_kuliah") or die ("gagal query".mysql_error());
- if (mysql_num_rows($qry)>0)
- {
- echo "<table border=1>";
- echo "<tr>";
- echo "<th>NIP</th>";
- echo "<th>Nama</th>";
- echo "<th>No HP</th>";
- echo "<th>LAmat</th>";
- echo "</tr>";
- //hasil query
- while ($row=mysql_fetch_array($qry))
- {
- echo "<tr>";
- echo "<td>".$row["nip"]."</td>";
- echo "<td>".$row["nama_dosen"]."</td>";
- echo "<td>".$row["hp"]."</td>";
- echo "<td>".$row["alamat"]."</td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- else
- {
- echo "tidak ada record";
- }
- ?>
- <p>tabel 2</p>
- <?php
- if (mysql_num_rows($qry1)>0)
- {
- echo "<table border=1>";
- echo "<tr>";
- echo "<th>Kode</th>";
- echo "<th>Nama Kuliah</th>";
- echo "<th>SKS</th>";
- echo "<th>semester</th>";
- echo "<th>nip</th>";
- echo "</tr>";
- //tampil query
- while ($row1=mysql_fetch_array($qry1))
- {
- echo "<tr>";
- echo "<td>".$row1["kode"]."</td>";
- echo "<td>".$row1["nama_kul"]."</td>";
- echo "<td>".$row1["sks"]."</td>";
- echo "<td>".$row1["semester"]."</td>";
- echo "<td>".$row1["nip"]."</td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- else
- {
- echo "tidak ada record";
- }
- ?>
- <p>join (tidak menggunakan $_GET[])</p>
- <?php
- $ambil="
- select daftar_dosen.nama, daftar_dosen.hp, daftar_dosen.alamat, mata_kuliah.kode, mata_kuliah.nama_kul, mata_kuliah.sks, mata_kuliah.semester,
- from daftar_dosen
- inner join mata_kuliah
- on daftar_dosen.nip = mata_kuliah.nip ";
- $hasil=mysql_query($ambil);
- //$join=mysql_fetch_array($qry3) or die ("gagal join".mysql_error());
- if (mysql_num_rows($hasil) > 0)
- {
- echo "<table border=1>";
- echo "<tr>";
- echo "<th>NIP</th>";
- echo "<th>Nama</th>";
- echo "<th>HP</th>";
- echo "<th>Alamat</th>";
- echo "<th>Kode</th>";
- echo "<th>Nama Kuliah</th>";
- echo "<th>SKS</th>";
- echo "<th>Semester</th>";
- echo "</tr>";
- while ($join=mysql_fetch_array($hasil))
- {
- echo "<tr>";
- echo "<td>".$join["nip"]."</td>";
- echo "<td>".$join["nama_kul"]."</td>";
- echo "<td>".$join["sks"]."</td>";
- echo "<td>".$join["semester"]."</td>";
- echo "<td>".$join["nama_kul"]."</td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment