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
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
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
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
Share on other sites

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'];

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.