Datnigz2002 Posted April 17, 2008 Share Posted April 17, 2008 I am kind of lost here. I am using Dreamweaver's update record feature. In my input field... If I type the following... "Todays date, My Name My issues Please call" On the page that pulls the info it looks like: "Todays date, My Name, My issues Please call" It doesn't recognize the returns for each line. How can I get it to display as it should without displaying it within an ugly giant input text box?? (Which does work however) Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/ Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 to get that info, you would do something like this: "Todays date, My Name\n \n My issues\n \n Please call"\n \n On the page that pulls the info it looks like:\n \n "Todays date, My Name, My issues Please call" Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519869 Share on other sites More sharing options...
rhodesa Posted April 17, 2008 Share Posted April 17, 2008 The reason is because HTML doesn't recognize new line characters. You can do one of the following: -use PHP to add <BR> tags with nl2br() -use PHP to manually replace new lines with <BR> tags using str_replace() or similar -wrap it in <pre> tags Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519872 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 if you use < p r e > (spacing it so it won't crap out again) in conjunction to my previous comment, you will not need to add < b r /> to each line., so it would go something like this: <pre> "Todays date, My Name\n \n My issues\n \n Please call"\n \n On the page that pulls the info it looks like:\n \n "Todays date, My Name, My issues Please call" </pre> //just as he said, pre works best Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519873 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 This is for end users to enter information to a database and I don't want to have them add html commands in their information. How exactly will I be able to use the PHP methods. I have never done this before and don't know where to start. I just need it for a small page that displays the paragraphs in a table. Just as you see my lines while your reading this now is what I'm looking for. Thanks Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519876 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 This is for end users to enter information to a database and I don't want to have them add html commands in their information. How exactly will I be able to use the PHP methods. I have never done this before and don't know where to start. I just need it for a small page that displays the paragraphs in a table. Just as you see my lines while your reading this now is what I'm looking for. Thanks have your text field automatically add the < p r e> before and < / p r e > at the end of all posts. they won't need to do it. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519878 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 How would I do that without the users seeing it or deleting it? Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519881 Share on other sites More sharing options...
GingerRobot Posted April 17, 2008 Share Posted April 17, 2008 Just use the nl2br() function. Thats what it's for. Not entirely sure where all this talk of < pre> tags has come from. Use it on the output from the database, not before you store it in the database. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519884 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 I tried the <p r e> it works. I just don't know where to put it so the users won't see it or delete it. as for the nl2br.. I have no idea how to use that function with my forum. Can you give an example? Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519885 Share on other sites More sharing options...
GingerRobot Posted April 17, 2008 Share Posted April 17, 2008 You use it when you echo out the post. If, for exampe, you have a loop echoing out the forum posts and the variable is called $post, you'd just do: echo nl2br($post); Without any of your code, i can't really help you beyond that. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519887 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 Sorry if I sound a little slow but I'm knew to this. I don't know where to put it in. This is what I have for my form. Can you show me where it goes. Then Maybe I will understand why it goes there. (: <form action="<?php echo $editFormAction; ?>" id="tstest" name="tstest" method="post"> <div align="center"> <table width="636" border="0"> <tr> <td height="24"><label> <input name="support" type="checkbox" id="support" value="Yes" <?php if (!(strcmp($row_user_lookup['Support'],"Yes"))) {echo "checked=\"checked\"";} ?> /> </label> ITHelp Thread | <label> <input name="imac" type="checkbox" id="imac" value="Yes" <?php if (!(strcmp($row_user_lookup['IMAC'],"Yes"))) {echo "checked=\"checked\"";} ?> /> </label> Configuration Thread | Created By: <select name="creator" id="creator"> <?php Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519898 Share on other sites More sharing options...
GingerRobot Posted April 17, 2008 Share Posted April 17, 2008 You dont use it on your form. I assume your form continues and you have a textarea somewhere? And this is the field you're having trouble with? You use it when you output the data, that is, after it has been submitted and stored in the database. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519902 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 I see so are you saying this the code would go in the page that is displaying the data from that particular field? This is what the code looks like around where the data shows up on the page. <td colspan="2" bgcolor="#E1E1E1" class="style30"> <div align="center"> <table width="606" border="0" cellspacing="2" cellpadding="2"> <tr> <td><div align="left"><?php echo $row_keywords['Ticket']; ?> <label></label> </div></td> </tr> </table> I tried playing around with the echo you see but just not getting it. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519911 Share on other sites More sharing options...
GingerRobot Posted April 17, 2008 Share Posted April 17, 2008 Try: td><div align="left"><?php echo nl2br($row_keywords['Ticket']); ?> Can you use tags around your code when you post please? Makes it much easier to read. Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519914 Share on other sites More sharing options...
Datnigz2002 Posted April 17, 2008 Author Share Posted April 17, 2008 I was trying to find the button for code.. Is there no button? If not I'll just type it. I kept fooling with it and I got it to work just as your example. Thanks alot for your help!!!! Link to comment https://forums.phpfreaks.com/topic/101613-records-do-not-display-as-paragraphs/#findComment-519917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.