tags:

views:

83

answers:

2

Hello,

I insert questions(which might be a few paragraphs) in a sql table using php and than i diplay them on a webpage.

but when i display the question it loses its formatting. I mean it will just show the whole question in one paragraph, even thou there were many paragraphs before.

<td width=\"700px\" bgcolor=\"#EAD57F\"><font color=\"#4A2A0B\">Question :</font><font color=\"#5E450B\">".$row2['Question']."</font></td>

$row2['Question'] --> is my question that i am getting from my sql table by running the SELECT query.

So if i post something like : a s d f

into my input box.

the output looks like : asdf

How should i resolve this?

Best Zeeshan

+4  A: 

You probably save your paragraphs separated by a "new line" character. To translate that in HTML check the nl2br PHP function (in HTML new line is the <br /> tag).

Tihauan
no .. this is not working
Zeeshan Rang
Could you post your submit and retrieve code?
Tihauan
+2  A: 

Are you storing them as plain text, or do they contain HTML tags? If they are stored as plain text you should put them in a <pre> tag or something equivalent in order to preserve the spacing. Alternatively, you could do the encoding into HTML, putting in <p> tags and such where necessary, but that is complicated and easy to get wrong.

krdluzni