Text wrapping in php comment script

Discussion in 'PHP' started by rotorio, Dec 25, 2008.

  1. #1
    Hi, I am new in this forum and also new to PHP. Atm I am trying to edit a simple comment script. Everything is done already but one last thing left. I want to make a word wrapping in comment text section. I have tried many ways but I have failed. If someone could help me I would be pleased:)

    Here are the lines from the script:

    echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n

    I want the text in this div to be wrapped.

    I have tried to asociate it with this script:

    $str = "sample text";
    echo wordwrap($str,15,"<br />\n",TRUE);

    But unfortunatelly, it didn't work. I must have done something wrong.

    Any ideas or suggestions?

    This is a link of the following free comment script:
    http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php

    Therefore, it has many bugs and this is one of them :p And the author of the script do not respond anymore.
     
    rotorio, Dec 25, 2008 IP
  2. rotorio

    rotorio Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Also I have just tried using css 3 property:
    word-wrap: break-word;

    But this only works in IE. Anyone has any suggestions?
     
    rotorio, Dec 25, 2008 IP
  3. rotorio

    rotorio Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I will copy the whole code to make it clear for all:

    echo "
    <link rel=\"stylesheet\" type=\"text/css\" href=\"comments.css\"/>
    ";

    $commentquery = mysql_query("SELECT * FROM comments WHERE tutorialid='$tutid' ORDER BY date DESC") or die(mysql_error());
    $commentNum = mysql_num_rows($commentquery);

    echo "<div id=\"currentcomments\" class=\"submitcomment\"><h3 class=\"formtitle\">Comments</h3>\n";
    echo "<p class=\"top\">Total: $commentNum (<a href=\"#post\" class=\"link\">comment</a>)</p>\n";

    $number = mysql_num_rows($commentquery)+1;
    while($commentrow = mysql_fetch_row($commentquery)){
    $number--;

    $commentbb = BBCode($commentrow[3]);
    $commentDate = formatDate($commentrow[4]);

    echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n
    <p>$commentbb</p>\n
    <p class=\"postedby\">";
    if($commentrow[2]){

    echo "<b class=\"name\">$commentrow[2]<b class=\"kb\">,</b></b>";
    }
    echo "<b class=\"date\">$commentDate</b> | <b class=\"number\">#$number</b></p>\n
    \n</div>";

    }
    echo "</div>";
    }
     
    rotorio, Dec 25, 2008 IP
  4. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    tamen, Dec 26, 2008 IP