genzedu777 Posted January 15, 2011 Share Posted January 15, 2011 Hi all, I realised as users register themselves in the registration form, they wrote their comments and experience in the comment box which was provided Example (this is the content which they have written) 'Sentence 1 - Abccafsafsafafasdfafasfafs Sentence 2 - dasddsadsadsadsdaddsda' As you can see, between Sentence 1 and 2 there is a break (space). However when we store it in our database, and generate it out as a webpage, the break (space) is gone, and sentence 1 and 2 merged Example 'Abccafsafsafafasdfafasfafsdasddsadsadsadsdaddsda' My question is, how can we prevent 2 different sentences from merging? Thanks Below is my code and attached it what has been generated after we have posted it in webpage cho '<div id="panel3">'; echo '<table>'; /***Tutor's Comments***/ echo'<div id="tutor_comments">'; echo '<br/><tr><td class="row_header">Tutor\'s Comments</td></tr>'; if (!empty($row2['tutor_comments'])) { echo '<tr><td>' . $row2['tutor_comments'] . '<br/><br/></td></tr>'; } /***Tutor's Commitments***/ echo '<tr><td class="row_header">Tutor\'s Commitment</td></tr>'; if (!empty($row2['tutor_commitment'])) { echo '<tr><td>' . $row2['tutor_commitment'] . '<br/><br/></td></tr>'; } /***Admin_comments***/ echo '<tr><td class="row_header">Admin\'s Comments</td></tr>'; if (!empty($row2['admin_comments'])) { echo '<tr><td>' . $row2['admin_comments'] . '<br/><br/></td></tr>'; } echo '</table>'; //End of Panel 3's table echo '</div>'; //End of tutor_comments DIV [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2011 Share Posted January 15, 2011 nl2br New-line characters (\r \n) don't have meaning in rendered html content (they do have meaning in the html source code.) Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159626 Share on other sites More sharing options...
Bradley99 Posted January 15, 2011 Share Posted January 15, 2011 The screenshot looks fine? Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159627 Share on other sites More sharing options...
denno020 Posted January 15, 2011 Share Posted January 15, 2011 I can see in your example code what you're trying to show as the problem, but I can't see the problem in the screenshot? Also, why are you mixing tables and div's? It makes ur code look pretty confusing, and I'm not sure why you would want to use them both? Denno Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159643 Share on other sites More sharing options...
genzedu777 Posted January 15, 2011 Author Share Posted January 15, 2011 Hi everyone, Maybe I didn't explain myself clearly. Currently we have a registration form for tutors to sign up, as they had completed signing up, their Profiles will be shown in our website, however we have an issue here, when tutors write their 'experiences' in the comments box, with break lines, the break lines could not execute. As you can see in the attachment (registration_form.jpg), when tutor types, I am a boy. I am a boy. I am a boy. //As you can see, the line break in the 2nd and 3rd sentence, however as their profile appear in our website, it does not execute the break lines, instead it shows I am a boy.I am a boy.I am a boy //Is there a way for the system to understand that there are line breaks in between sentences, and execute exactly what the user has entered? Thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159796 Share on other sites More sharing options...
Pikachu2000 Posted January 15, 2011 Share Posted January 15, 2011 nl2br New-line characters (\r \n) don't have meaning in rendered html content (they do have meaning in the html source code.) ^^^ Did you try this? Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159800 Share on other sites More sharing options...
genzedu777 Posted January 15, 2011 Author Share Posted January 15, 2011 Hi Pikachu, how should I do it? Is that how I should do it in bold? Thanks /***Tutor's Comments***/ echo'<div id="tutor_comments">'; echo 'Tutor\'s Comments<br/>'; if (!empty($row2['tutor_comments'])) { echo 'nl2br('. $row2['tutor_comments'] . ')<br/><br/>'; } /***Tutor's Commitments***/ echo 'Tutor\'s Commitment<br/>'; if (!empty($row2['tutor_commitment'])) { echo 'nl2br(' . $row2['tutor_commitment'] . ')<br/><br/>'; } /***Admin_comments***/ echo 'Admin\'s Comments<br/>'; if (!empty($row2['admin_comments'])) { echo '' . $row2['admin_comments'] . '<br/><br/>'; } Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159813 Share on other sites More sharing options...
Pikachu2000 Posted January 15, 2011 Share Posted January 15, 2011 You don't enclose a php function in quotes like that to echo its output. echo nl2br($row2['tutor_comments']) . '<br/><br/>'; Quote Link to comment https://forums.phpfreaks.com/topic/224489-no-break-in-between-different-sentences/#findComment-1159815 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.