Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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