Jump to content

Recommended Posts

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 ;)

Link to comment
https://forums.phpfreaks.com/topic/151514-solved-problem-using-nl2br/
Share on other sites

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 />");
    }

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']}

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 />";
    }
?>

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.

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 />";
    }
?>

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  :o

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.