how query four tables from the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • g30r9e
    New Member
    • Nov 2012
    • 1

    #1

    how query four tables from the database

    Hi,

    I have a question for u...

    I have more than four tables rigth now..but i want to query only four tables among them to get the teacher name and subject name base on the date in the date table..here are my four query that i made before..

    Code:
    $view = mysql_query("SELECT DISTINCT absen.id_matakuliah, dosen.id_dosen, dosen.nama_dosen, kelasdosen.id_dosen, kelasdosen.id_matakuliah, matakuliah.id_matakuliah, matakuliah.nama_matakuliah FROM absen, dosen, kelasdosen, matakuliah WHERE absen.id_matakuliah=matakuliah.id_matakuliah and matakuliah.id_matakuliah=kelasdosen.id_matakuliah and kelasdosen.id_dosen=dosen.id_dosen and absen.tanggal='2012-10-23'");
    and when I run it in php...i got an error which says..

    "Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs \absenkelas\abs en\regis\test1. php"

    this the php syntaks that i made

    Code:
    $view = mysql_query("select absen.id_matakuliah, dosen.id_dosen, dosen.nama_dosen, kelasdosen.id_dosen, kelasdosen.id_matakuliah, matakuliah.id_matakuliah, matakuliah.nama_matakuliah from absen, dosen, kelasdosen, matakuliah where absen.id_matakuliah=matakuliah.id_matakuliah and matakuliah.id_matakuliah=kelasdosen.id_mataku
    liah and kelasdosen.id_dosen=dosen.id_dosen and absen.tanggal='2012-10-23'");
      if($no = 1)
      {
         while($hasil=mysql_fetch_array($lihat))
         {
    	echo "<tr> <td>$no</td> <td>$hasil[nama_dosen]</td> <td>$hasil[nama_matakuliah]</td> </tr>";
      	++$no;
         }
    i'm an indonesian so i'm using indonesia language in my syntaks...thank s before for helping me...i really need the answer
    Last edited by Rabbit; Nov 6 '12, 01:28 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    On line 5, you're trying to fetch data from a variable called $lihat. But as far as I can tell, $lihat is not set to anything. Shouldn't you be trying to fecth data from $view? It's the variable that has the result of the query you ran.

    Comment

    Working...