Cory94bailly Posted March 28, 2009 Share Posted March 28, 2009 function printSticky($result1) { echo "<table>\n"; while($news = mysql_fetch_assoc($result1)) { echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo "\n</table><br />"; } Where would I put nl2br()??? I tried many things and got errors everywhere.. lol Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/ Share on other sites More sharing options...
ram4nd Posted March 28, 2009 Share Posted March 28, 2009 Put echoed string in it. function printSticky($result1) { echo nl2br("<table>\n"); while($news = mysql_fetch_assoc($result1)) { echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo nl2br("\n</table><br />"); } Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795791 Share on other sites More sharing options...
Cory94bailly Posted March 28, 2009 Author Share Posted March 28, 2009 Put echoed string in it. function printSticky($result1) { echo nl2br("<table>\n"); while($news = mysql_fetch_assoc($result1)) { echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo nl2br("\n</table><br />"); } That's not what I want to be turned into <br>s.. I want this: {$news['news_body']} Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795794 Share on other sites More sharing options...
steelaz Posted March 28, 2009 Share Posted March 28, 2009 I assume you want to add line breaks to your $news['news_body']. If so, add nl2br() before echoing it: <?php function printSticky($result1) { $news['news_body'] = nl2br($news['news_body']); echo "<table>\n"; while($news = mysql_fetch_assoc($result1)) { echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo "\n</table><br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795795 Share on other sites More sharing options...
Cory94bailly Posted March 28, 2009 Author Share Posted March 28, 2009 Hmm, I'm not sure if it is a problem with my coding or what..! http://etsoldiers.com/massattack/index.php Login as an admin, click the first one, click edit (Right near the title..), and look, it looks fine. Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795797 Share on other sites More sharing options...
wildteen88 Posted March 28, 2009 Share Posted March 28, 2009 This line: $news['news_body'] = nl2br($news['news_body']); Should be within then while loop <?php function printSticky($result1) { echo "<table>\n"; while($news = mysql_fetch_assoc($result1)) { $news['news_body'] = nl2br($news['news_body']); echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo "\n</table><br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795819 Share on other sites More sharing options...
Cory94bailly Posted March 28, 2009 Author Share Posted March 28, 2009 This line: $news['news_body'] = nl2br($news['news_body']); Should be within then while loop <?php function printSticky($result1) { echo "<table>\n"; while($news = mysql_fetch_assoc($result1)) { $news['news_body'] = nl2br($news['news_body']); echo <<<HTML <span class="announcement">Announcement:</span> <b>{$news['news_title']}</b><br /> <hr width="300" align="left" /> {$news['news_body']} <br /> HTML; } echo "\n</table><br />"; } ?> Wooh! I love you Thanks Quote Link to comment https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/#findComment-795822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.