underline Posted October 27, 2009 Share Posted October 27, 2009 I'm trying to figure out when I echo a row (using mysql_fetch_array, then using $row['column name']) it outputs as a single line, ignoring the page breaks that exist in the database. When I make a <textarea> and set the echo as the value, it includes the breaks. Is there another way to output the spaces or will I have to edit the database values? Thanks in advance Here is a part from the form: <?php $result = mysql_query("SELECT * FROM system WHERE UserID='$id'"); $row = mysql_fetch_array($result); ?> <tr> <td>Name</td> <td><?php echo $row['Name']; ?></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/179230-echoing-mysql-query-with-page-breaks/ Share on other sites More sharing options...
mrMarcus Posted October 27, 2009 Share Posted October 27, 2009 and...what do these page breaks look like? <br />? \n? EDIT: you might want/need to look into nl2br() Quote Link to comment https://forums.phpfreaks.com/topic/179230-echoing-mysql-query-with-page-breaks/#findComment-945606 Share on other sites More sharing options...
underline Posted October 27, 2009 Author Share Posted October 27, 2009 I use phpMyAdmin- I can't necessarily tell what they are. When I view the page source it shows as <br> (but I assume it could still be different) Quote Link to comment https://forums.phpfreaks.com/topic/179230-echoing-mysql-query-with-page-breaks/#findComment-945612 Share on other sites More sharing options...
underline Posted October 27, 2009 Author Share Posted October 27, 2009 and...what do these page breaks look like? <br />? \n? EDIT: you might want/need to look into nl2br() That worked! Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/179230-echoing-mysql-query-with-page-breaks/#findComment-945616 Share on other sites More sharing options...
mikesta707 Posted October 27, 2009 Share Posted October 27, 2009 they are newline characters. In plain text (which text areas are) line breaks are caused by new lines. In html they are caused by the line break tage (<br />) Marcus is correct, you should look into the nl2br() function edit: oh nvm then too late Quote Link to comment https://forums.phpfreaks.com/topic/179230-echoing-mysql-query-with-page-breaks/#findComment-945618 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.