By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

how query four tables from the database

P: 1
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..

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
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,366
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.