spaceman12 Posted December 25, 2010 Share Posted December 25, 2010 hello guys, suppose I want to echo out the text given below exactly as what has been set against, including the line breaks. How do I do it? coz each time i did it so, there s no line breaks but the output is usually a dense lump of words with no paragraphs. I took her out it was a Friday night I wore cologne to get the feeling right We started making out and she took off my pants But then I turned on the TV And that's about the time she walked away from me Nobody likes you when you're 23 I'm still more amused by TV shows What the hell is ADD? My friends say I should act my age What's my age again? What's my age again? please help P.S. The whole set of phrase give above are treated as a single variable coz I use a WHILE loops when making an echo. tthanks Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/ Share on other sites More sharing options...
.josh Posted December 25, 2010 Share Posted December 25, 2010 would be better if you showed the code actually outputting the text, but you probably need to be using nl2br or simply wrapping your text with <pre>...</pre> tag. Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151405 Share on other sites More sharing options...
the182guy Posted December 25, 2010 Share Posted December 25, 2010 Web browsers do not recognise new lines as other programs do such as notepad/text editors. Web browsers will only show a new line if there is a <br /> tag or a CSS setting or the text is wrapped individually in <p> tags. Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151406 Share on other sites More sharing options...
spaceman12 Posted December 25, 2010 Author Share Posted December 25, 2010 $selectSUP="SELECT * FROM member_support WHERE Ticket_ID='$_GET[TID]'"; $locateSUP=mysql_query($selectSUP); while($fetchSUP=mysql_fetch_array($locateSUP)) { $status=$fetchSUP['Status']; $date=$fetchSUP['Date']; $subject=$fetchSUP['Subject']; $type=$fetchSUP['Type']; $message=$fetchSUP['Message']; } echo "Ticket ID"." ".":"." ".$_GET['TID']."</br>"; echo "Status"." ".":"." ".$status."</br>"; echo "Opened On"." ".":"." ".$date."</br>"; echo "Type"." ".":"." ".$type."</br>"; echo "<br></br><br></br>"; echo $message; $message = "I took her out it was a Friday night I wore cologne to get the feeling right We started making out and she took off my pants But then I turned on the TV And that's about the time she walked away from me Nobody likes you when you're 23 I'm still more amused by TV shows What the hell is ADD? My friends say I should act my age What's my age again? What's my age again?" Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151412 Share on other sites More sharing options...
.josh Posted December 25, 2010 Share Posted December 25, 2010 only thing i really see wrong here is that it should be <br> or <br/> by itself, one for each line break you want, not </br> (linebreak tag does not have open and closing tags, it is a single tag). Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151413 Share on other sites More sharing options...
spaceman12 Posted December 25, 2010 Author Share Posted December 25, 2010 wont "\r\n" used in the php mail fucntion help here? Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151414 Share on other sites More sharing options...
Pikachu2000 Posted December 25, 2010 Share Posted December 25, 2010 echo nl2br($message); Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151415 Share on other sites More sharing options...
spaceman12 Posted December 25, 2010 Author Share Posted December 25, 2010 echo nl2br($message); Thank you so much...............it so worked out like a charms...... Link to comment https://forums.phpfreaks.com/topic/222642-echo-out-with-line-breaks-and-paragraphs-set/#findComment-1151416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.