I'm trying to output from mysql using php. The SQL query that I'm outputting contains several joins and some of the values are NULL. When I echo the output I get empty spaces for the NULL values. How do I get rid of the empty space? I have line breaks between each value that I want to output, but the NULL values are just placing an empty space. So my output looks a bit like this.
What it looks like
Dave Smith
Subject 1
Subject 3
John Smith
Subject 1
Subject 2
Subject 4
What I'd like it to look like
Dave Smith
Subject 1
Subject 3
John Smith
Subject 1
Subject 2
Subject 4
I have tried a few of the php trim functions, but none seem to work. The relevant code is below.
$resultSet = $db->query ("...my query");
echo $resultSet -> num_rows;
While($rows = $resultSet ->fetch_assoc())
{
$FirstName = ($rows['First_Name']);
$Surname = ($rows['Surname']);
$subject1 = ($rows['subject1']);
$subject2 = ($rows['subject2']);
$subject3 = ($rows['subject3']);
$subject4 = ($rows['subject4']);
$output .= "<p> $FirstName $Surname <br/> Chosen Subjects <br/> $subject1 <br/> $subject2 <br/>
$subject3 <br/> $subject4 </p>";
}