dongshi8038 2018-03-28 22:03
浏览 43
已采纳

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.

  • 写回答

1条回答 默认 最新

  • dongnigeng1295 2018-03-28 22:07
    关注

    You can use wordwrap for that.

    wordwrap($row['comment'], 50, '<br>')
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch