sore mas mo nanya dunk
saya mau menampilkan hasil query dari 4 tabel yg terelasi misal saya masukkan medrecnya data2 yag lain keluar
tabel saya
1. datasosial(medrec(pk), nama, tgllahir)
2. kunjungan(idkunjungan(pk), medrec, diagutama, diasekunder)
3. icd10(kd_penyakit(pk), penyakit)
4. icd10b (kd_penyakit(pk), penyakit)
relasi
1. datasosial(medrec)= kunjungan(medrec)
2. kunjunagan(diagutama)=icd10(kd_penyakit)
3. kunjungan(diasekunder)=icd10b(kd_penyakit)

sql saya berjalan dimysql
SELECT kunjungan.idkunjung, kunjungan.medrec, kunjungan.masuk, kunjungan.keluar, kunjungan.jnsrawat, kunjungan.jnskunjung, kunjungan.carakeluar, kunjungan.diagutama, kunjungan.diasekunder, datasosial.nama, datasosial.tglahir, datasosial.umurthn, datasosial.umurhari, datasosial.jnskelamin, datasosial.bblahir, icd10.penyakit AS diagnosautama, icd10b.penyakit AS diagnosasekunder FROM kunjungan, datasosial, icd10, icd10b WHERE kunjungan.diagutama=icd10.kd_penyakit AND kunjungan.diasekunder=icd10b.kd_penyakit AND datasosial.medrec=kunjungan.medrec AND kunjungan.medrec='0000001'
tp kl pake scrip kede dibawah muncul keterangan "Column 'medrec' in where clause is ambiguous"
  1. <!DOCTYPE html>
  2. <html >
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <style type="text/css">
  7. <!--
  8. body {
  9. font: 100% Verdana, Arial, Helvetica, sans-serif;
  10. background: #666666;
  11. margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
  12. padding: 0;
  13. text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
  14. color: #000000;
  15. }
  16. .oneColFixCtrHdr #container {
  17. width: auto; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
  18. background: #FFFFFF;
  19. margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
  20. border: 1px solid #000000;
  21. text-align: left; /* this overrides the text-align: center on the body element. */
  22. }
  23. .oneColFixCtrHdr #header {
  24. background: #DDDDDD;
  25. padding: 0 10px 0 20px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
  26. }
  27. .oneColFixCtrHdr #header h1 {
  28. margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
  29. padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
  30. }
  31. .oneColFixCtrHdr #mainContent {
  32. padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
  33. background: #FFFFFF;
  34. }
  35. .oneColFixCtrHdr #footer {
  36. padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
  37. background:#DDDDDD;
  38. }
  39. .oneColFixCtrHdr #footer p {
  40. margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
  41. padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
  42. }
  43. -->
  44. </style></head>
  45.  
  46. <body class="oneColFixCtrHdr">
  47.  
  48. <div id="container">
  49. <div id="header">
  50. <h1>Resume</h1>
  51. <!-- end #header --></div>
  52. <div id="mainContent">
  53. <h1>HASIL</h1>
  54.  
  55. <?php
  56. error_reporting("E_ALL ^ E_NOTICE");
  57. mysql_connect("localhost", "root", "");
  58. mysql_select_db("datapx");
  59.  
  60. $bagianWhere = "";
  61.  
  62. if (isset($_POST['medrec']))
  63. {
  64. $medrec = $_POST['medrec'];
  65. if (empty($bagianWhere))
  66. {
  67. $bagianWhere .= "medrec = '$medrec'";
  68. }
  69. else
  70. {
  71. $bagianWhere .= " AND medrec LIKE '$medrec'";
  72. }
  73. }
  74.  
  75.  
  76.  
  77.  
  78. $query = "SELECT kunjungan.idkunjung, kunjungan.medrec, kunjungan.masuk, kunjungan.keluar, kunjungan.jnsrawat, kunjungan.jnskunjung, kunjungan.carakeluar, kunjungan.diagutama, kunjungan.diasekunder, datasosial.nama, datasosial.tglahir, datasosial.umurthn, datasosial.umurhari, datasosial.jnskelamin, datasosial.bblahir, icd10.penyakit AS diagnosautama, icd10b.penyakit AS diagnosasekunder FROM kunjungan, datasosial, icd10, icd10b WHERE kunjungan.diagutama=icd10.kd_penyakit AND kunjungan.diasekunder=icd10b.kd_penyakit AND datasosial.medrec=kunjungan.medrec AND kunjungan.medrec=".$bagianWhere;
  79. $hasil = mysql_query($query) or die (mysql_error());
  80.  
  81.  
  82. echo "<table border='1' cellpadding = '2' cellspacing = '1' align = 'left'>";
  83. echo "<tr><td>id kunjungan</td><td><tr><td>MEDREC</td><td>NAMA</td></td><td>TGL MASUK</td><td>TGL KELUAR</td><td>JENIS KELAMIN</td><td>TGL Lahir</td><td>UMUR TAHUN</td>
  84. <td>UMUR HARI</td><td>JENIS KUNJUNGAN</td><td>JENIS PERAWATAN</td><td>CARA KELUAR RS</td><td>BERAT BADAN LAHIR</td><td>DIAGNOSA UTAMA</td> <td>ICD10</td><td>DIAGNOSA SEKUNDER</td><td>IC10</td></tr>";
  85.  
  86. while ($data = mysql_fetch_array($hasil))
  87. {
  88. echo "<tr><td>".$data['idkunjung']."</td><td>".$data['medrec']."</td><td>".$data['nama']."</td><td>".$data['masuk']."</td><td>".$data['keluar']."</td><td>".$data['jnskelamin']."</td><td>".$data['tglahir']."</td>
  89. <td>".$data['umurthn']."</td><td>".$data['umurhari']."</td><td>".$data['jnskunjung']."</td><td>".$data['jnsrawat']."</td><td>".$data['carakeluar']."</td><td>".$data['bblahir']."</td><td>".$data['penyakit']."</td>
  90. <td>".$data['kd_penyakit']."</td><td>".$data['diasekunder']."</td><td>".$data['kd_penyakit']."</td></tr>";
  91. }
  92. echo "</table>";
  93. ?>
  94. <!-- end #mainContent --></div>
  95. <div id="footer">
  96. <table width="317" border="1" >
  97. <tr>
  98. <th width="107" height="32" align="left" scope="row">TANGGAL : </th>
  99. <td width="199"><span id="date"><?php print date('d-m-Y'); ?></span></td>
  100. </tr>
  101. <tr>
  102. <th height="40" align="left" scope="row">JAM :</th>
  103. <td><script type="text/javascript">
  104. //set timezone
  105. <?php date_default_timezone_set('Asia/Jakarta'); ?>
  106. //buat object date berdasarkan waktu di server
  107. var serverTime = new Date(<?php print date('Y, m, d, H, i, s, 0'); ?>);
  108. //buat object date berdasarkan waktu di client
  109. var clientTime = new Date();
  110. //hitung selisih
  111. var Diff = serverTime.getTime() - clientTime.getTime();
  112. //fungsi displayTime yang dipanggil di bodyOnLoad dieksekusi tiap 1000ms = 1detik
  113. function displayServerTime(){
  114. //buat object date berdasarkan waktu di client
  115. var clientTime = new Date();
  116. //buat object date dengan menghitung selisih waktu client dan server
  117. var time = new Date(clientTime.getTime() + Diff);
  118. //ambil nilai jam
  119. var sh = time.getHours().toString();
  120. //ambil nilai menit
  121. var sm = time.getMinutes().toString();
  122. //ambil nilai detik
  123. var ss = time.getSeconds().toString();
  124. //tampilkan jam:menit:detik dengan menambahkan angka 0 jika angkanya cuma satu digit (0-9)
  125. document.getElementById("clock").innerHTML = (sh.length==1?"0"+sh:sh) + ":" + (sm.length==1?"0"+sm:sm) + ":" + (ss.length==1?"0"+ss:ss);
  126. }
  127. </script>
  128. <body onload="setInterval('displayServerTime()', 1000);">
  129. <br/>
  130. <span id="clock"><?php print date('H:i:s'); ?></span></td>
  131. </tr>
  132. </table>
  133. <a href="/ridha/index.php">Kembali ke halaman Sebelumnya</a>
  134. <!-- end #footer --></div>
  135. <!-- end #container --></div>
  136. </body>
  137. </html>
15110
Please login to answer!
/sangkep/answer/add-json/nogzip/1
/sangkep/answer/send-notification