1

I used

<textarea name="question" class="input" width="250"></textarea> 

to add data in sql. i used multi line , in database also data is stored in multi line only.

Then i used

$question=$row['1'];
echo "<tr><td colspan='5'>",$row[1],"</td></tr>

to display the data but the data are displaying in single line . how to make it appear in mulit line like as in database.

4
  • 1
    wrap the text in <pre> tags Commented Jul 27, 2012 at 13:45
  • <?php echo(nl2br($row[1])); ?> Commented Jul 27, 2012 at 13:45
  • or use nl2br(), but not in the textarea Commented Jul 27, 2012 at 13:46
  • @VainFellowman regarding code he wants to display it in a table cell - so nl2br() should be fine. Commented Jul 27, 2012 at 13:46

2 Answers 2

5

Correct

echo "<tr><td colspan='5'>",$row[1],"</td></tr>

To

echo "<tr><td colspan='5'>".nl2br($row[1])."</td></tr>";
Sign up to request clarification or add additional context in comments.

1 Comment

user <pre> tag or try nl2br()
2

You need to convert the newlines to HTML line breaks. Try PHP's nl2br:

echo "<tr><td colspan='5'>".nl2br($row[1])."</td></tr>

1 Comment

nl2br($row[1], /*is_xhtml*/ false), HTML 4 does not allow closing slash <br />.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.