CrazeD Posted June 5, 2007 Share Posted June 5, 2007 Is there a way to make the contents of my MySQL table the same as the way it went in? For example, if I insert: 1 2 3 4 5 6 into my MySQL table, it comes back out as: 1 2 3 4 5 6 Is there a way to fix that? My field type is TEXT, if that matters. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/ Share on other sites More sharing options...
shortj75 Posted June 5, 2007 Share Posted June 5, 2007 i had the same problem i fixed it by adding a break <br> after my query like this $getnum=mysql_query("SELECT * from yourtable"); while($getnum2=mysql_fetch_array($getnum)){ echo "$getmun2[tablerow]<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268639 Share on other sites More sharing options...
CrazeD Posted June 5, 2007 Author Share Posted June 5, 2007 No, I'm not talking spacing between each row. Like say you have a textarea, and you enter: "blah blah blah blah blah blah blah blah blah blah" It goes into the MySQL table like this: "blah blah blah blah blah blah blah blah blah blah" Is there any way to change that? Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268660 Share on other sites More sharing options...
Yesideez Posted June 5, 2007 Share Posted June 5, 2007 echo nl2br($getnum2[tablerow]); Like that? Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268662 Share on other sites More sharing options...
CrazeD Posted June 5, 2007 Author Share Posted June 5, 2007 No no no, you're not listening. It goes into the table as a one-line string, it doesn't have breaks in it. Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268664 Share on other sites More sharing options...
wildteen88 Posted June 5, 2007 Share Posted June 5, 2007 How are you inserting it into your database table? Post the relevant parts of your code here. If you enter line1 line2 another line b l a h It should go into the database as you have typed it. However when you get the data back out of the database and display it in the browser you may find it displays as this: line1line2another lineblah This is nothing to do with PHP or MySQL but the browser itself. Web browsers ignore most whitespace characters (\n, \r, etc). In order for the browser to display your textareas you have entered it in the textarea you will need to use the html equivalent, eg <br /> for newlines. Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268756 Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 No no no, you're not listening. It goes into the table as a one-line string, it doesn't have breaks in it. I think you are the one not listening. Anytime you enter data into a DB from a textarea it has \n characters or new line characters. www.php.net/nl2br converts the \n to < br /> so it is visible by the webbrowser. I bet if you viewed the source of the data currently printed it would look like it did when you entered it into the DB. Give it a try and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268764 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.