PHP: Displaying Paragraphs from MySQL Database
Let the image explain:
Without this function, the browser won't read the paragraph properly from MySQL Database. The new line will be ignored as shown in the image above (blue border).
In order to display the paragraph properly we will use this PHP Function:
Just enclose the "value" with nl2br as shown above.
That's it! Comment below for any clarification.
Without this function, the browser won't read the paragraph properly from MySQL Database. The new line will be ignored as shown in the image above (blue border).
In order to display the paragraph properly we will use this PHP Function:
Definition and UsageThe function above will achieve the "red border" as shown in the image.
The nl2br() function inserts HTML line breaks (<br> or <br />) in front of each newline (\n) in a string.
echo "<td>LEARNING OBJECTIVES (LO)</td>"; echo nl2br("<td>" . $row['learning_objective'] . "</td>"); echo "</tr>";
Just enclose the "value" with nl2br as shown above.
That's it! Comment below for any clarification.