468,514 Members | 1,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

how query four tables from the database


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..

Expand|Select|Wrap|Line Numbers
  1. $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_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\absenkelas\absen\regis\test1.php"

this the php syntaks that i made

Expand|Select|Wrap|Line Numbers
  1. $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
  2. liah and kelasdosen.id_dosen=dosen.id_dosen and absen.tanggal='2012-10-23'");
  3.   if($no = 1)
  4.   {
  5.      while($hasil=mysql_fetch_array($lihat))
  6.      {
  7.     echo "<tr> <td>$no</td> <td>$hasil[nama_dosen]</td> <td>$hasil[nama_matakuliah]</td> </tr>";
  8.       ++$no;
  9.      }
i'm an indonesian so i'm using indonesia language in my syntaks...thanks before for helping me...i really need the answer
Nov 6 '12 #1
1 1554
12,513 Expert Mod 8TB
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.
Nov 6 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by lev | last post: by
reply views Thread by Ralph Guzman | last post: by
reply views Thread by info | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.