Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Preformatted Text From Form to DB

Featured Replies

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.

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

  • 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 by Neji

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.