aj123cd Posted July 26, 2012 Share Posted July 26, 2012 In the DB text field I am keeping different type of date formats. To display the date I am using different type of code with echo. Can anyone advice me is there any other method available. nl2br <pre></pre> Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/ Share on other sites More sharing options...
carugala Posted July 26, 2012 Share Posted July 26, 2012 use the DB datatypes Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364489 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 I am using LONGTEXT(MySQL) thank you. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364490 Share on other sites More sharing options...
Psycho Posted July 26, 2012 Share Posted July 26, 2012 I am using LONGTEXT(MySQL) He meant use one of the database DATE types: date, datetime, timestamp, time, & year. If you use something other than a MySQL date/time format for date/time values you are preventing the ability to use many of the built-in functions for dealing with date/time value. You only need to store a date once. You can then output that date in any way you need to using either the MySQL or PHP functions as needed. If you ONLY need the date (and not the time component), then you should use the 'date' type. You would store the value in the format YYYY-MM-DD. Then when you retrieve the value, just use the PHP date() function to output it in whatever format you wish. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364492 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 In the DB text field I am keeping different type of date formats. To display the date I am using different type of code with echo. Can anyone advice me is there any other method available. nl2br <pre></pre> #Please accept my apology My typing mistake. NOT DATE IT SHOULD BE DATA Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364496 Share on other sites More sharing options...
cyberRobot Posted July 26, 2012 Share Posted July 26, 2012 So, what is the question? It kind of sounds like you're asking how to display information from a database. If so, could you explain what you're doing now and what you're looking to do. If you don't like the method you're currently using, what don't you like about it? Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364547 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 Stores the DATA in html formatted information in a MySQL database eg: <p>Hello</p><ul><li>1</li><li>2</li></ul> I just want to retrieve html formatted text which is stored in a MySQL database & display it on a page. But the page is displaying the html coding rather than the formatted output. Expected result was Hello 1 2 BUT I am getting the following result. <p>Hello</p><ul><li>1</li><li>2</li></ul> I have tried all the method, THANKYOU Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364670 Share on other sites More sharing options...
cyberRobot Posted July 26, 2012 Share Posted July 26, 2012 What is the code used to display the data? There's probably a function like htmlentities() being used on the data. Removing the function might give you the expected results. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364674 Share on other sites More sharing options...
Pikachu2000 Posted July 26, 2012 Share Posted July 26, 2012 Code? Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364675 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 INSERT code $sql = "INSERT INTO messages ( date, user_id, topic_id, body ) VALUES( NOW(),'". 5 ."','" . 1 ."','" . $postedValue ."');"; $res = mysql_query($sql); to display $sql = "INSERT INTO messages ( date, user_id, topic_id, body ) VALUES( NOW(),'". 5 ."','" . 1 ."','" . $postedValue ."');"; $res = mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364685 Share on other sites More sharing options...
Jessica Posted July 26, 2012 Share Posted July 26, 2012 You posted the same code for both. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364692 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 I am sorry this is the code for display $threadsql = "SELECT * FROM messages"; $threadresult = mysql_query($threadsql); $threadrow = mysql_fetch_assoc($threadresult); echo $threadrow['body']; Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364699 Share on other sites More sharing options...
Barand Posted July 26, 2012 Share Posted July 26, 2012 Between "$postedvalue" being posted and getting into that variable, what are you doing to it? Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364712 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 using CKeditor to post the value. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364715 Share on other sites More sharing options...
Barand Posted July 26, 2012 Share Posted July 26, 2012 Good luck with your problem. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364718 Share on other sites More sharing options...
aj123cd Posted July 26, 2012 Author Share Posted July 26, 2012 thank you why I can not get HELP :'( Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364740 Share on other sites More sharing options...
Pikachu2000 Posted July 26, 2012 Share Posted July 26, 2012 The problem is obviously on line 42. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364747 Share on other sites More sharing options...
Barand Posted July 27, 2012 Share Posted July 27, 2012 thank you why I can not get HELP :'( When we ask you for further information that we need in order to help you, you don't give it. If you don't help us we can't help you. Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364759 Share on other sites More sharing options...
aj123cd Posted July 27, 2012 Author Share Posted July 27, 2012 This my code. Thank you. <?php include("../includes/config.php"); if (isset($_POST['submit']) ) { $sql = "INSERT INTO forum_messagess ( date, user_id, topic_id, body ) VALUES( NOW(),'". 5 ."','" . 1 ."','" . $postedValue ."');"; $res = mysql_query($sql); $threadsql = "SELECT * FROM forum_messages"; $threadresult = mysql_query($threadsql); $threadrow = mysql_fetch_assoc($threadresult); echo $threadrow['body']; } ?> <form action="" method="post"> <textarea name="body" rows="5" cols="15"></textarea> <input type="submit" name="submit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364796 Share on other sites More sharing options...
Jessica Posted July 27, 2012 Share Posted July 27, 2012 Is CKEditor a rich text editor? It's going to convert the < to < Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364868 Share on other sites More sharing options...
gizmola Posted July 27, 2012 Share Posted July 27, 2012 Is CKEditor a rich text editor? It's going to convert the ^^^^^^^^^^^^ Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364925 Share on other sites More sharing options...
cyberRobot Posted July 27, 2012 Share Posted July 27, 2012 Does this help at all? http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/ProcessHTMLEntities Assuming that CKEditor is the one converting things to HTML entities, you could try asking their forum: http://cksource.com/forums/ Quote Link to comment https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364930 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.