473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how query four tables from the database

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
1 1632
Rabbit
12,516 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

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

Similar topics

0
by: Dan Baker | last post by:
I'm trying to write a stand-alone application which will query the contact database used in Outlook (or maybe Exchange Server). I have no idea where to start looking. Any advice? Dan Baker
1
by: lev | last post by:
Hello, Is there an ad hoc way to query a remote database in Oracle a la OPENROWSET statement in MS SQL? Thank you. Lev
0
by: Ralph Guzman | last post by:
TASK: I have to generate a report with all categories, subcategories and products in database. PROBLEM: I want to write one query that will return: 1. category 2. subcategory: determined by...
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
0
by: info | last post by:
i researched for a while on the net and found that more people have this problem, but could not get an answer. i am very new to MySql. linux - feudora i log into mysql using "root" when...
2
by: me | last post by:
I have written a query that joins four or five tables. One table has 30,000 rows. Another table has only 200. I want to only return the 200 or so rows in the smaller table and columns from the...
1
dlite922
by: dlite922 | last post by:
hey fellas (and ladies) I need help with making a query. My tables are: (Simplified) case: id violatorID number
3
samikhan83
by: samikhan83 | last post by:
i am having a problem in getting data from four tables based on a common field in one query. 1. i have product,open_balance,purchase,sales tables and product_id is primary key of product and...
9
by: BhanteU | last post by:
I have written code to close all open reports, or close all forms (except a couple), using code similar to the following: While Application.Reports.Count > 0 DoCmd.Close acReport,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.