May 10, 201115 yr I want to be able to enter text into a form and have it inserted into the database in the same format that it was entered. Basically, I want any line breaks to be recorded so when I pull the text from the DB it comes out with line breaks, or even better wrapped in <p> tags.
May 10, 201115 yr Author I'd prefer to just do it with PHP if it's easily done. If not, then I'll certainly look into the editors.
May 10, 201115 yr Author Sorry, I wasn't clear. I meant I'd prefer a smaller solution and not have to include anything much extra as it's only going to be for one field. As this is in Wordpress, it seems to have applied <p> tags to it automatically. I just didn't expect it to do it from a db entry. Thanks for the help anyway. Edited May 10, 201115 yr by Neji
May 11, 201115 yr If you don't want to use a blob field then you could do something like... $sql = "INSERT INTO `mytable` (`id`, `name`, `field`) VALUES (null, 'John Smith', '<p>".nl2br($_POST['mytextfield'], true)."</p>');";
Create an account or sign in to comment