I am trying to loop through my mysql query result and print out some of the data. What I expected was when I added " " to the end of the print message, it would print each message on a separate line. But for some reason its all on one line. Why is this and how can I make each message be on a separate line?
while($row = mysql_fetch_array($result))
{
$message = $row['action_type'] . " " . $row['identifier'] . " @ " . " placeholder ";
if($row['location'] !== NULL)
{
$message += " on " . $row['location'] . "
";
}
echo $message . "
";
}
Your $message
variable is ending with a /n
when it should be . Try updating it to fix (unless of course, in that section of the code it's on purpose):
$message += " on " . $row['location'] . "
";
The actual echo
statement ends with a real newline, so this should work properly in a command-line, but not in a browser.
To get it to display on a new line in a browser, change the instances to
<br />
:
echo $message . "<br />";