noel-kreiss

Untitled

May 6th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <?php
  2. include "db.inc.php";
  3. ?>
  4.  
  5. <!doctype html>
  6. <html>
  7. <head> tes percobaan</head>
  8. <body>
  9. <?php
  10. $qry=mysql_query("select * from daftar_dosen");
  11. $qry1=mysql_query("select * from mata_kuliah") or die ("gagal query".mysql_error());
  12.  
  13. if (mysql_num_rows($qry)>0)
  14. {
  15. echo "<table border=1>";
  16. echo "<tr>";
  17. echo "<th>NIP</th>";
  18. echo "<th>Nama</th>";
  19. echo "<th>No HP</th>";
  20. echo "<th>LAmat</th>";
  21. echo "</tr>";
  22.  
  23. //hasil query
  24.  
  25. while ($row=mysql_fetch_array($qry))
  26. {
  27. echo "<tr>";
  28. echo "<td>".$row["nip"]."</td>";
  29. echo "<td>".$row["nama_dosen"]."</td>";
  30. echo "<td>".$row["hp"]."</td>";
  31. echo "<td>".$row["alamat"]."</td>";
  32. echo "</tr>";
  33. }
  34. echo "</table>";
  35. }
  36. else
  37. {
  38. echo "tidak ada record";
  39. }
  40. ?>
  41.  
  42. <p>tabel 2</p>
  43.  
  44. <?php
  45. if (mysql_num_rows($qry1)>0)
  46. {
  47. echo "<table border=1>";
  48. echo "<tr>";
  49. echo "<th>Kode</th>";
  50. echo "<th>Nama Kuliah</th>";
  51. echo "<th>SKS</th>";
  52. echo "<th>semester</th>";
  53. echo "<th>nip</th>";
  54. echo "</tr>";
  55.  
  56. //tampil query
  57.  
  58. while ($row1=mysql_fetch_array($qry1))
  59. {
  60. echo "<tr>";
  61. echo "<td>".$row1["kode"]."</td>";
  62. echo "<td>".$row1["nama_kul"]."</td>";
  63. echo "<td>".$row1["sks"]."</td>";
  64. echo "<td>".$row1["semester"]."</td>";
  65. echo "<td>".$row1["nip"]."</td>";
  66. echo "</tr>";
  67. }
  68. echo "</table>";
  69. }
  70. else
  71. {
  72. echo "tidak ada record";
  73. }
  74. ?>
  75.  
  76. <p>join (tidak menggunakan $_GET[])</p>
  77. <?php
  78. $ambil="
  79. select daftar_dosen.nama, daftar_dosen.hp, daftar_dosen.alamat, mata_kuliah.kode, mata_kuliah.nama_kul, mata_kuliah.sks, mata_kuliah.semester,
  80. from daftar_dosen
  81. inner join mata_kuliah
  82. on daftar_dosen.nip = mata_kuliah.nip ";
  83. $hasil=mysql_query($ambil);
  84. //$join=mysql_fetch_array($qry3) or die ("gagal join".mysql_error());
  85.  
  86. if (mysql_num_rows($hasil) > 0)
  87. {
  88. echo "<table border=1>";
  89. echo "<tr>";
  90. echo "<th>NIP</th>";
  91. echo "<th>Nama</th>";
  92. echo "<th>HP</th>";
  93. echo "<th>Alamat</th>";
  94. echo "<th>Kode</th>";
  95. echo "<th>Nama Kuliah</th>";
  96. echo "<th>SKS</th>";
  97. echo "<th>Semester</th>";
  98. echo "</tr>";
  99.  
  100. while ($join=mysql_fetch_array($hasil))
  101. {
  102. echo "<tr>";
  103. echo "<td>".$join["nip"]."</td>";
  104. echo "<td>".$join["nama_kul"]."</td>";
  105. echo "<td>".$join["sks"]."</td>";
  106. echo "<td>".$join["semester"]."</td>";
  107. echo "<td>".$join["nama_kul"]."</td>";
  108. echo "</tr>";
  109. }
  110. echo "</table>";
  111. }
  112.  
  113.  
  114. ?>
  115. </body>
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment