Jump to content

problem with mySQL query statement


husslela03

Recommended Posts

Hello:

 

I am having a problem with my mySQL query statement

I will post the table structure below, and the statement i have now, and what i want to obtain:

 

1) What I want to do is get the assignment names from the assignment table that are related to the course name in the "courses" table and list all the assignments.

 

I keep getting an error stating: 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in on line 40

 

and I know that I get this error because the query is NOT returning anything.

 

Here is the statement I was using and before that I also tried RIGHT JOIN and LEFT JOIN, but still am receiving the same error.

$sql=mysql_query("SELECT * FROM courses, assignments FULL JOIN assignments ON courses.courseID=assignments.courseID");

here is the code that i am putting it in for my php statements:

while($row = mysql_fetch_array($sql))
  					{
  					
  					echo $username. ' ' .$row['assignmentName']. '<br />';
  					
  					} 

Here is my table structures

 

'courses' table

courseID courseName

1 English

2 Math

3 Science

4 Psychology

 

'assignments' table:

 

assignmentID courseID assignmentName assignmentMaxValue assignmentWeight

1   1             Homework1                             100                             10

2   1     Homework2                                     100                             10

3 1   Quiz1                                               50                               10

 

 

Any help would be greatly appreaciated!

Link to comment
https://forums.phpfreaks.com/topic/198577-problem-with-mysql-query-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.