RajaSekar
RajaSekar

Reputation: 398

PHP displaying Text using line break

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.

Upvotes: 1

Views: 1115

Answers (2)

Nimit Dudani
Nimit Dudani

Reputation: 4860

Correct

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

To

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

Upvotes: 5

Matt Humphrey
Matt Humphrey

Reputation: 1554

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

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

Upvotes: 2

Related Questions