tmyonline Posted May 6, 2008 Share Posted May 6, 2008 Hi guys: My original message contains some specific format, such as some words are bold, others are italics. Also, the message contains several paragraphs,... I had this message saved to MySQL. By the time I retrieve this message, the format is lost, i.e., the words that are supposed to be bold are no longer bold (same problem with italics). More seriously, all the paragraphs are somehow combined into one big paragraph. How should I resolve this issue ? I appreciate your help. Thanks. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted May 6, 2008 Share Posted May 6, 2008 Well, how are they being rendered as bold? Are you using some html tags? BB tags? Or what? As for apparent loss of new lines, you should use the nl2br() function on that kind of data being output for a web browser - it'll turn your new lines into <br > tags for the browser. Quote Link to comment Share on other sites More sharing options...
realjumper Posted May 6, 2008 Share Posted May 6, 2008 To get the paragraph and line breaks to dispay correctly....... // Retrieve all the data from the table $result = mysql_query("SELECT * FROM your_table") or die(mysql_error()); // store the record of the table into $row $row= mysql_fetch_array( $result ); $text = nl2br($row[text]); echo "$text"; The line breaks and paragraphs are in your db, eeven though you can't see them.... nl2br will recover them. I'm in a rush so I can't get into your other formatting issues, but I'll check back later Quote Link to comment Share on other sites More sharing options...
tmyonline Posted May 7, 2008 Author Share Posted May 7, 2008 Thanks realjumper and GingerRobot, With your recommendation on using nl2br(), my paragraphs appear now. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 Did you happen to run strip_tags() on the input before you put it into the database? >_> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.