html表数据(<;td>;<;/td>;)文本不拆分(如果不拆分)';t包含空格


html tabledata(<td></td>) text not splitting if it doesn't contain a space

我制作了一个小的注释/日志脚本,在数据库中放入用户名、注释和日期。

我使用POST方法将其发送到我的PHP脚本中。然后我把所有的东西都显示在一张表中。但是,如果表数据中不包含空格,则"注释"会"遍历"该表数据。这是因为剧本不知道在哪里分割,所以它只是把它整个打印出来。

这是我的代码:

<?php
    if(isset($_POST['HandleAction']))
    {   
        if($_POST['User'] != '' && $_POST['Text'] != '')
        {
            $User = $_POST['User'];
            $Text = $_POST['Text'];
            mysql_query("INSERT INTO Comments VALUES('$User', '$Text', CURRENT_TIMESTAMP)");
        }
        else
        {
            echo "<script>alert('Vul alle velden in om.');</script>";
        }
    }
    echo "Comments" . "<br>" . "<hr>";
    echo "<table id='Comments'>";
    $results = mysql_query("SELECT * FROM Comments");
    while($row = mysql_fetch_array($results))
    {
        echo "<tr>  <th width='720'>" . $row['Name'] . "</th>   <th>" . $row['Date'] . "</th>   </tr>";
        echo "<tr>  <td>" . $row['Text'] . "</td>   </tr>";
    }
    echo "</table>";    
?>

长话短说:如果我的字符串不包含字符串,并且使我的路径过长,那么它就无法拆分。

提前谢谢。

您需要将换行样式应用于太长的td。尽管这可能会使显示失真,因为长字可能被分割在多行上。你可以像twitter一样限制用户可以键入的字符数量,或者验证输入,使每个单词的字符数量达到最大值。

希望能帮助

请在此处查看有关换行的更多信息