duanhui5344 2014-05-02 18:25
浏览 55
已采纳

Php试图在break语句中插入一个break行

Code

Look at the second echo under the second do

do {
    echo "<strong>Topic:". $row_AllTopics['topic'] . "</strong><br>";

    mysql_select_db($database_Select, $Select);
    $query_Comments = sprintf("SELECT * FROM comments where ((event_id=%s) AND (topic_id=%s)) ", $_POST['event_id'], $row_AllTopics['id']);
    $Comments = mysql_query($query_Comments, $Select) or die(mysql_error());
    $row_Comments = mysql_fetch_assoc($Comments);
    $totalRows_Comments = mysql_num_rows($Comments);

    do {
        // This is the echo in question.
        echo $row_Comments['comment'] . "Posted by: ". $row_Comments['poster'] . "
";
    } while ($row_Comments = mysql_fetch_assoc($Comments));


} while ($row_AllTopics = mysql_fetch_assoc($AllTopics));

Output

(This text is all centered align on the screen )

Topic:computer
linuxPosted by: andy linuxPosted by: andy Topic:computer
Posted by: Topic:ji
poPosted by: andy Topic:drive
makPosted by: andy Topic:new
nicePosted by: andy Topic:golf
holePosted by: andy plPosted by: andy
  • 写回答

3条回答 默认 最新

  • donglulong0877 2014-05-02 18:31
    关注

    You can use nl2br() function in PHP by:

    echo nl2br($row_Comments['comment'] . "Posted by: ". $row_Comments['poster'] . "
    ");
    

    This will convert to <br/>.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部