new lines in form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ja NE

    new lines in form

    well, it is time for some fine tuning of my application, after adding
    that banner script for which I needed percentage solution, I would like
    to fix my forum scripts...
    when someone write some text in form's textarea and then
    enter
    new line (btw, is that \r or \n or combination?) I'm not "getting" that
    new line but space. what can I do to "recieve" and store (in mysql db)
    text with newlines instead of spaces. and, even better, to replace that
    newline with </p>\n<p>...

    tnx again

    --
    Ja NE
    fotografija = zapisano svjetlom | fotozine = foto-e-zin

    --
  • Ja NE

    #2
    Re: new lines in form

    Ja NE <hidden@mail.zz > wrote:

    ....ok.
    have it ;-))

    $tekst = preg_replace("/\r\n/", "\n", $tekst);
    $tekst = preg_replace("/\n/", "</p>\n<p>", $tekst);

    thank you "manual" ;-)
    [color=blue]
    > well, it is time for some fine tuning of my application, after adding
    > that banner script for which I needed percentage solution, I would like
    > to fix my forum scripts...
    > when someone write some text in form's textarea and then
    > enter
    > new line (btw, is that \r or \n or combination?) I'm not "getting" that
    > new line but space. what can I do to "recieve" and store (in mysql db)
    > text with newlines instead of spaces. and, even better, to replace that
    > newline with </p>\n<p>...
    >
    > tnx again[/color]


    --
    Ja NE
    fotografija = zapisano svjetlom | fotozine = foto-e-zin

    --

    Comment

    • IWT

      #3
      Re: new lines in form

      Ja NE wrote:[color=blue]
      > when someone write some text in form's textarea and then
      > enter
      > new line (btw, is that \r or \n or combination?) I'm not "getting" that
      > new line but space. what can I do to "recieve" and store (in mysql db)
      > text with newlines instead of spaces. and, even better, to replace that
      > newline with </p>\n<p>...[/color]


      I've just done something very similar:

      $description=$_ POST['textarea'];

      $description = strip_tags($des cription); // Remove any HTML tags
      $description = "<p>".$descript ion; // Add <p> to start
      $description = str_replace("\r \n","</p><p>", $description); // Replace
      new lines with paragraph

      if(substr($desc ription,-3)=="<p>") // Remove last <p> from description
      $description = substr($descrip tion,0,-3);

      Comment

      • Jerry Stuckle

        #4
        Re: new lines in form

        Ja NE wrote:[color=blue]
        > well, it is time for some fine tuning of my application, after adding
        > that banner script for which I needed percentage solution, I would like
        > to fix my forum scripts...
        > when someone write some text in form's textarea and then
        > enter
        > new line (btw, is that \r or \n or combination?) I'm not "getting" that
        > new line but space. what can I do to "recieve" and store (in mysql db)
        > text with newlines instead of spaces. and, even better, to replace that
        > newline with </p>\n<p>...
        >
        > tnx again
        >[/color]

        Jane,

        That's the way HTML works - if you look at the page source and you'll
        see the newlines in there. But processing the HTML gets rid of them.

        You need to use something like PHP's nl2br() function to convert newline
        characters to html breaks.

        It can get very confusing when a newline "isn't" a newline!


        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...