0

I'm using a Textarea element to allow users to update their "status".

All works fine but new lines disapear when I retrieve the text from the SQL? It SAVES them ok, and I can see them in PhpMyAdmin, but when I run this code after retrieving all the updates:

while($row = mysql_fetch_array($StatusResult))
{
  echo $row['Text'];
  if (GetLoggedOnId() == $_GET["UId"])
  {
    echo "<form>
          <input type=\"submit\" value=\"X\" name=\"REMOVE\"/>
          </form>";
  }
  echo "<br/>";
}

it seems to just "forget" where linebreaks were.

2 Answers 2

6

Try this method when printing the string: nl2br

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I'm not sure whether to accept your answer or Arjan's, since you both gave a working answer at almost the same time.. :/. Wish we could accept two.
Do what feels the best for you. Glad I could help.
I suppose I'll go with Baszz, since he has less reputation.
3

HTML ignores newline characters. Use nl2br() to convert the newline characters to <br> breaks that will display as expected in HTML.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.