Forums
This topic is locked
BLOB field display
Posted 28 Mar 2002 10:24:24
1
has voted
28 Mar 2002 10:24:24 Julio Taylor posted:
hellohow can i display the contents of a BLOB MySQL field on a page so that it shows the spaces and line breaks in tghe content?
thanks!
Replies
Replied 28 Mar 2002 16:38:12
28 Mar 2002 16:38:12 Peter R replied:
poolio,
Use the following:
<pre id=code><font face=courier size=2 id=code><?php echo str_replace("\n","<br>",$rs_your_recordset->Fields("your_field")?> </font id=code></pre id=code>
The important part for your question is:
<pre id=code><font face=courier size=2 id=code>str_replace("\n","<br>",......) </font id=code></pre id=code>
This replaces <pre id=code><font face=courier size=2 id=code>\n </font id=code></pre id=code> with html <pre id=code><font face=courier size=2 id=code><br> </font id=code></pre id=code>'s so that your linebreaks will show.
Use the following:
<pre id=code><font face=courier size=2 id=code><?php echo str_replace("\n","<br>",$rs_your_recordset->Fields("your_field")?> </font id=code></pre id=code>
The important part for your question is:
<pre id=code><font face=courier size=2 id=code>str_replace("\n","<br>",......) </font id=code></pre id=code>
This replaces <pre id=code><font face=courier size=2 id=code>\n </font id=code></pre id=code> with html <pre id=code><font face=courier size=2 id=code><br> </font id=code></pre id=code>'s so that your linebreaks will show.
Replied 28 Mar 2002 18:05:36
28 Mar 2002 18:05:36 chief monkey replied:
poolio,
why are you storing text in a blob field, you would be better using the text field.
as for converting \n to <br> you can use the php function nl2br()
www.php.net/nl2br()
George
Everybody has got to be somewhere
Replied 28 Mar 2002 20:11:41
28 Mar 2002 20:11:41 Peter R replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
you would be better using the text field.
as for converting \n to <br> you can use the php function nl2br()
www.php.net/nl2br()
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Good point about the text field. nl2br() huh? You mean I've been doing it the long way all this time??!! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> See what happens when you're not a programmer. I think I'll go check that out myself. Apparently I'm gonna be a student for life, which is ok 'cause I love them girls!
Thanks,
Peter
you would be better using the text field.
as for converting \n to <br> you can use the php function nl2br()
www.php.net/nl2br()
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Good point about the text field. nl2br() huh? You mean I've been doing it the long way all this time??!! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> See what happens when you're not a programmer. I think I'll go check that out myself. Apparently I'm gonna be a student for life, which is ok 'cause I love them girls!
Thanks,
Peter
Replied 28 Mar 2002 21:09:51
28 Mar 2002 21:09:51 Bruno Mairlot replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Good point about the text field. nl2br() huh? You mean I've been doing it the long way all this time??!! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> See what happens when you're not a programmer. I think I'll go check that out myself. Apparently I'm gonna be a student for life, which is ok 'cause I love them girls!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Hehe, don't worry...PHP 4.2.0 is more than 2000 functions, so its quite an accomplishment to know even 1/4 of them.
But, my advice there would be...before doing something so simple, check for it on www.php.net, because if its about Web/HTTP particuliarities, then there is 95% of chance that is integrated into PHP ...
One particular section very useful, IMHO, is the String functions. They are extremely useful, and its definitely not a lost of time to learn them, or at least to see what they do.
Bruno
--- Better to die trying, than never try at all ---
Good point about the text field. nl2br() huh? You mean I've been doing it the long way all this time??!! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> See what happens when you're not a programmer. I think I'll go check that out myself. Apparently I'm gonna be a student for life, which is ok 'cause I love them girls!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Hehe, don't worry...PHP 4.2.0 is more than 2000 functions, so its quite an accomplishment to know even 1/4 of them.
But, my advice there would be...before doing something so simple, check for it on www.php.net, because if its about Web/HTTP particuliarities, then there is 95% of chance that is integrated into PHP ...
One particular section very useful, IMHO, is the String functions. They are extremely useful, and its definitely not a lost of time to learn them, or at least to see what they do.
Bruno
--- Better to die trying, than never try at all ---