如何从用户输入的数据中插入p标签

I am setting up a form where the user will enter a memo into a textarea. That info will be inserted into a database with php. I want to output the info from the database as an html page with paragraph tags (the paragraph tags would be inserted before and after returns). Since the user is not inputting p tags when they are typing the memo, they would need to be inserted on output. Any ideas how I can accomplish this?

$query1 = "SELECT d.title, d.memo, d.time, e.first_name ";
$query1 .= "FROM employee AS e, digital_memo AS d ";
$query1 .= "WHERE e.employee_id = d.employee_id AND ";
$query1 .= "d.time > DATE_SUB(NOW(), INTERVAL " . $days . " HOUR)";
$result1 = mysqli_query($connection, $query1);

$data = $row["memo"];
$paragraph_markers = array("

","
");
$data = str_replace($paragraph_markers,'</p><p>',$data);

while($row = mysqli_fetch_assoc($result1)){
    //output data
    echo "<p><span style='font-weight:700; font-size:1.2em;'>" . $row["title"] . "</span>";
    echo "<span style='float:right; color:grey;'>" . (date ('m-d-Y', strtotime($row["time"]))) ;
    echo ", " . $row["first_name"] . "</span></p>" . "<br/>" ;

    echo "<p>" . $row["memo"] . "</p>";

};

I tried to add the query, result, and other info $data and $paragraph markers to swap with p tags. when it is output to html, nothing is output. please let me know if more info is needed or I did not explain this well? am I working along the right lines here? thanks in advance!

figured out what I was trying to do...

$data = mysqli_fetch_assoc($result);

$paragraph_markers = array("

","
");
$data = str_replace($paragraph_markers,'</p><p>',$data["memo"]);

There's no need for fancy replacing of to <p>, simply store the raw memo and then use nl2br($row\['memo'\]) to output it.