Jump to content

TEXT format


aj123cd

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364492
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364496
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364670
Share on other sites

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);

Link to comment
https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364685
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/266263-text-format/#findComment-1364796
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.