PHP - 逐位回显sql结果

the below code is working as expected:

    if($con){
        mysqli_select_db($con, "db3");
        $query1 = "SELECT * FROM data WHERE id = $id";
        $result = mysqli_query($con, $query1);
        while ($row = mysqli_fetch_array($result)){
            echo "<b>" . "Sent by: " . $row['uname'] . ":" . "</b>" . "<br>" . $row['comment'] . "<br>" . "<u>" . "Sent on: " . $row['time'] . "</u>" . "<br><br>";
                }

My issue is the the 'comment' value can be pretty long and prints off screen. Is there any way to echo out the 'comment' value 50 characters at a time for example, or insert a line break within it.

Any help appreciated. Thanks.

You can use wordwrap for that.

wordwrap($row['comment'], 50, '<br>')