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:


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


//run query
    $isGrade = "SELECT
                            gradeID, grade
                            assignID = '$assignID'
                            subID = '$subID'
                            uNo = '$uNo'
            $g = mysql_query($isGrade) or die(mysql_error());
                $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>';

Edited by dlaverick

4 Years
Discussion Span
Last Post by dlaverick

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 :-/


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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.