Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

Empfohlene Antworten

Veröffentlicht

Hallo,

mit Hilfe eines Formulars schreibe ich Texte in die Datenbank, die dann auf der Seite erscheinen.

Jedoch werden die Texte plain in die Datenbank geschrieben, ohne <p>, <b> oder ähnliches.

Es ist natürlich kein Problem das mit der Hand zu machen, jedoch ist dieses Formular für Anwender gedacht die sich auf sowas nicht konzentrieren können.

Wie bekomme ich es hin, dass automatisch ein <p> um den Text kommt?

Hallo, wie geht es?


Gut, und selber?

soll also so in die DB geschrieben werden:

<p>Hallo, wie geht es?</p>

<p>Gut, und selber?</p>

fg

Vielleicht als Anhaltspunkt für dich. So ersetze ich die "Newlines" mit Perl ...

$db_comment =~ s/\015\012|\015|\012/<br>  /sg;

Du musst jetzt halt z.B. aus einer Leerzeile ein <p> machen, wenn du das willst.

Und wenn du das Rad nicht neu erfinden willst, dann kannst dich ja mal mit bbcode beschäftigen, da gibt es auch tolle Module.

Bearbeitet von bigvic

Da du weder DBMS noch Sprache angegeben hast nehm ich nun einfach mal PHP + MySQL

Wenn du den Text zbsp aus einer Textarea in ein "text" feld speicherst, speichert er auch die new lines mit

in PHP gibts dann ne funktion die nl2br heist womit du das ganze wieder ausgeben kannst.

wenn du da unbedingt <p> tags drum haben moechtest solltest du dich mit ereg / preg_match auseinander setzen :)

Ted

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.