I am running a check from my Db to see if a grade exists, if it does then spit out the grade inside a link.
If not then spit out another link.

The bit that includes the grade where a grade exists works a treat, it just does not like it if the variable is NULL.

Any ideas to sort this will be much appreciated!

here is what is returned:

ab710e8c07afd0868c8a5d0093855bb3

the row where no grade appears needs to show the link: <a href="submit/grade.php?id='.$subID.'">G</a>

So:

//run query
    $isGrade = "SELECT
                            gradeID, grade
                        FROM
                            Grade
                        WHERE
                            assignID = '$assignID'
                        AND
                            subID = '$subID'
                        AND 
                            uNo = '$uNo'
            ";      
            $g = mysql_query($isGrade) or die(mysql_error());
            while($row=mysql_fetch_assoc($g)){
                $gradeID = $row['gradeID'];
                $grade = $row['grade'];


                if ($gradeID === NULL) {
                     echo '<td><a href="submit/grade.php?id='.$subID.'">G</a></td>';

                }else if ($gradeID != NULL){
                    echo '<td><a href="submit/grade.php?id='.$subID.'">'.$grade.'</a></td>';
                } 
                echo '</tr>';
            }

Shouldn't you be checking $grade instead of $gradeID ?

doesn't matter which I check as they both come out of the same table.
The problem is if the assignment hasn't been marked there will be no data to use. hense the if NULL show the link to mark the paper. :-/

doesn't matter which I check as they both come out of the same table.

Of course it matters. ID is probably an auto increment column, so it will never be NULL. Grade on the other hand can be NULL.

If you still disagree, can you show your table structure, and the rows of data in the image (an sql dump).

Sorry I didn't explain it well. You are right in what you say :-)

I have 2 tables one for the submission and one to record the grade.

if the paper has not been graded there will be no record of a grade in the grade table, so no gradeID or grade.

So in my while loop it will hit a NULL or no value for that row.

I think because there is no record it just moves on, so maybe if I can tell it to give the 'missing record' a dummy value instead maybe I could work with that. I just don't know how to go about it :-/

Show table and data. Without it's hard to guess/test.

thanks for your time but I over came by adding another column to submission named marked an ran a query using that instead.

so if marked = 0 it isnt marked echo out link
so if marked = 1 it IS marked echo out different link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.