displaying line breaks?

Discussion in 'HTML' started by paul814@excite.com, May 19, 2008.

  1. Guest

    I have a MYSQL DB that people enter data into through a multiline
    textbox, and then i display the data on a search results page. Here
    is how I display it:

    while($row=mysql_fetch_object($rs)){

    print "<div class=\"message\">";
    print " <h3>" . $row->itdate . "</h3>";
    print " <h5>" . $row->itname . "</h5>";
    print " <h4>" . $row->itcomments ."</h4>";
    print "############### END OF RECORD ###############";
    print "</div>";

    }

    this however does not display line breaks, everything runs on, can I
    do something so that line breaks are displayed and my data is
    displayed just like it was entered?

    thanks.
     
    , May 19, 2008
    #1
    1. Advertising

  2. Scripsit :

    > print " <h3>" . $row->itdate . "</h3>";
    > print " <h5>" . $row->itname . "</h5>";
    > print " <h4>" . $row->itcomments ."</h4>";


    That's semantically all wrong, since those pieces of texts are not
    headings. A heading is a heading for something; but you have no copy
    text.

    Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    level heading immediately after a 3rd level heading?

    Try learning the basics of HTML first, really.

    > print "############### END OF RECORD ###############";


    We used such dividers in line printer output in the early 1970s.

    > this however does not display line breaks, everything runs on, can I
    > do something so that line breaks are displayed and my data is
    > displayed just like it was entered?


    It belongs to the basics of HTML that a line break is equivalent to a
    space (or, in some contexts, an empty string) and that you need markup
    such as <br> to generate a line break. It also belongs to the basics of
    HTML that you should not format the text in a fixed manner but let
    browsers do the division into lines, as they do unless you prevent it.

    Apparently you're trying to make some user input to be converted to
    HTML. It's pointless to re-invent the wheel when there's existing
    software for such purposes, for doing it right.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 19, 2008
    #2
    1. Advertising

  3. richard Guest

    On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"
    <> wrote:

    >Scripsit :
    >
    >> print " <h3>" . $row->itdate . "</h3>";
    >> print " <h5>" . $row->itname . "</h5>";
    >> print " <h4>" . $row->itcomments ."</h4>";

    >
    >That's semantically all wrong, since those pieces of texts are not
    >headings. A heading is a heading for something; but you have no copy
    >text.
    >
    >Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >level heading immediately after a 3rd level heading?
    >


    The so called "order" of headers usage is a myth.
    The tag is merely intended for displaying text in a certain fixed
    style. So if one wanted to display <h1> then an <h5> right below or
    above, it makes no difference.

    If I want to display an <h5> then an <h1> purely for looks, that's my
    business.
     
    richard, May 19, 2008
    #3
  4. richard wrote:
    > On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"


    >>
    >> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >> level heading immediately after a 3rd level heading?
    >>

    >
    > The so called "order" of headers usage is a myth.
    > The tag is merely intended for displaying text in a certain fixed
    > style. So if one wanted to display <h1> then an <h5> right below or
    > above, it makes no difference.
    >
    > If I want to display an <h5> then an <h1> purely for looks, that's my
    > business.
    >


    Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    have semantic meaning and refer to the level of headings within the
    structure of a document. If you wish different size text then style it.

    /* some classes for styling */
    ..date{ font-size: 1.5em; }
    ..name { font-size: 1.2em; }
    ..comments{ font-size: 1.0em; }

    example:

    <div class="date"><?php echo $row->itdate; ?></div>

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, May 19, 2008
    #4
  5. richard Guest

    On Mon, 19 May 2008 12:29:27 -0400, "Jonathan N. Little"
    <> wrote:

    >richard wrote:
    >> On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"

    >
    >>>
    >>> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >>> level heading immediately after a 3rd level heading?
    >>>

    >>
    >> The so called "order" of headers usage is a myth.
    >> The tag is merely intended for displaying text in a certain fixed
    >> style. So if one wanted to display <h1> then an <h5> right below or
    >> above, it makes no difference.
    >>
    >> If I want to display an <h5> then an <h1> purely for looks, that's my
    >> business.
    >>

    >
    >Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    >have semantic meaning and refer to the level of headings within the
    >structure of a document. If you wish different size text then style it.
    >
    >/* some classes for styling */
    >.date{ font-size: 1.5em; }
    >.name { font-size: 1.2em; }
    >.comments{ font-size: 1.0em; }
    >
    >example:
    >
    ><div class="date"><?php echo $row->itdate; ?></div>



    Which is what the h tags were designed to do in the first place.
    Act as a shortcut to styling. Which were in use well before CSS came
    around. So if I can do the same thing in CSS then why have h tags at
    all?
     
    richard, May 19, 2008
    #5
  6. Guest

    Ok though aside from the styling of this text though...is there
    something I could add to this that would format text just as it was
    entered in my text box?

    SO IF WAS ENTERED:
    this is a test, this is a test.
    test

    test2
    IT WOULD DISPLAY:
    this is a test, this is a test.
    test

    test2


    so it would skip lines when the actual input skips lines?
    thanks.

    On May 19, 12:29 pm, "Jonathan N. Little" <> wrote:
    > richard wrote:
    > > On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"

    >
    > >> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    > >> level heading immediately after a 3rd level heading?

    >
    > > The so called "order" of headers usage is a myth.
    > > The tag is merely intended for displaying text in a certain fixed
    > > style. So if one wanted to display <h1> then an <h5> right below or
    > > above, it makes no difference.

    >
    > > If I want to display an <h5> then an <h1> purely for looks, that's my
    > > business.

    >
    > Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    > have semantic meaning and refer to the level of headings within the
    > structure of a document. If you wish different size text then style it.
    >
    > /* some classes for styling */
    > .date{ font-size: 1.5em; }
    > .name { font-size: 1.2em; }
    > .comments{ font-size: 1.0em; }
    >
    > example:
    >
    > <div class="date"><?php echo $row->itdate; ?></div>
    >
    > --
    > Take care,
    >
    > Jonathan
    > -------------------
    > LITTLE WORKS STUDIOhttp://www.LittleWorksStudio.com
     
    , May 19, 2008
    #6
  7. richard wrote:

    > Which is what the h tags were designed to do in the first place.


    No they are not. They are, as Jonathan said, semantic headings, just
    like those outlines you wrote for English class - if you ever went to
    high school.

    Outline:

    A. My Main Title
    1. Chapter one
    a. Paragraph about ...
    b. Another paragraph about ...
    2. Chapter two
    a. Another paragraph ...
    i. Keep going with sublevels...
    ii. Keep going with sublevels...

    > Act as a shortcut to styling. Which were in use well before CSS came
    > around. So if I can do the same thing in CSS then why have h tags at
    > all?


    Of course you may style <hx> elements different than the browser
    default, but this has absolutely nothing to do with their true semantic
    meaning.

    Please don't post false advice in the future.

    --
    -bts
    -Friends don't let friends drive Windows
     
    Beauregard T. Shagnasty, May 19, 2008
    #7
  8. In alt.html, wrote:

    > Ok though aside from the styling of this text though...is there
    > something I could add to this that would format text just as it was
    > entered in my text box?


    I answered that question in comp.lang.php

    --
    -bts
    -Friends don't let friends drive Windows
     
    Beauregard T. Shagnasty, May 19, 2008
    #8
  9. wrote:
    > Ok though aside from the styling of this text though...is there
    > something I could add to this that would format text just as it was
    > entered in my text box?
    >
    > SO IF WAS ENTERED:
    > this is a test, this is a test.
    > test
    >
    > test2
    > IT WOULD DISPLAY:
    > this is a test, this is a test.
    > test
    >
    > test2


    One way is with the php function nl2br

    http://us.php.net/manual/en/function.nl2br.php
    PHP: nl2br - Manual


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, May 19, 2008
    #9
  10. Guest

    this does not seem to work without echoing like I am doing here:

    print " <h4>" . $row->itcomments ."</h4>";

    I need it to work with that.


    On May 19, 1:27 pm, "Jonathan N. Little" <> wrote:
    > wrote:
    > > Ok though aside from the styling of this text though...is there
    > > something I could add to this that would format text just as it was
    > > entered in my text box?

    >
    > > SO IF WAS ENTERED:
    > > this is a test, this is a test.
    > > test

    >
    > > test2
    > > IT WOULD DISPLAY:
    > > this is a test, this is a test.
    > > test

    >
    > > test2

    >
    > One way is with the php function nl2br
    >
    > http://us.php.net/manual/en/function.nl2br.php
    > PHP: nl2br - Manual
    >
    > --
    > Take care,
    >
    > Jonathan
    > -------------------
    > LITTLE WORKS STUDIOhttp://www.LittleWorksStudio.com
     
    , May 19, 2008
    #10
  11. wrote:

    > this does not seem to work without echoing like I am doing here:
    >
    > print " <h4>" . $row->itcomments ."</h4>";
    >
    > I need it to work with that.


    echo " <h4>" . nl2br($row->itcomments) ."</h4>";
    echo " <h4><pre>" . $row->itcomments ."<pre></h4>";
    echo " <h4 style='white-space:pre'>" . $row->itcomments ."</h4>";

    .... *sigh* ...

    --
    ----------------------------------
    Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

    Now listening to: Andru Donalds - Dream On (1999) - [10] Holdin' on to You
    (3:44) (94.625000%)
     
    Iván Sánchez Ortega, May 19, 2008
    #11
  12. C A Upsdell Guest

    richard wrote:
    > On Mon, 19 May 2008 12:29:27 -0400, "Jonathan N. Little"
    > <> wrote:
    >
    >> richard wrote:
    >>> On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"
    >>>> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >>>> level heading immediately after a 3rd level heading?
    >>>>
    >>> The so called "order" of headers usage is a myth.
    >>> The tag is merely intended for displaying text in a certain fixed
    >>> style. So if one wanted to display <h1> then an <h5> right below or
    >>> above, it makes no difference.
    >>>
    >>> If I want to display an <h5> then an <h1> purely for looks, that's my
    >>> business.
    >>>

    >> Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    >> have semantic meaning and refer to the level of headings within the
    >> structure of a document. If you wish different size text then style it.
    >>
    >> /* some classes for styling */
    >> .date{ font-size: 1.5em; }
    >> .name { font-size: 1.2em; }
    >> .comments{ font-size: 1.0em; }
    >>
    >> example:
    >>
    >> <div class="date"><?php echo $row->itdate; ?></div>

    >
    > Which is what the h tags were designed to do in the first place.
    > Act as a shortcut to styling. Which were in use well before CSS came
    > around. So if I can do the same thing in CSS then why have h tags at
    > all?


    Utterly wrong. Header tags have semantic meaning. If you wanted
    styling in the olden days, long, long ago, before CSS, you should have
    used the FONT tag, not header tags.
     
    C A Upsdell, May 20, 2008
    #12
  13. Andy Dingley Guest

    On 19 May, 17:29, "Jonathan N. Little" <> wrote:
    > richard wrote:
    > > On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"

    >
    > >> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    > >> level heading immediately after a 3rd level heading?


    > > The so called "order" of headers usage is a myth.



    > Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    > have semantic meaning and refer to the level of headings within the
    > structure of a document. If you wish different size text then style it.


    Richard isn't _absolutely_ incorrect here (and twice a day he knows
    what time it is).

    I would even go so far as to say that he's right and Jukka is wrong.

    To look at your point, "H1-H5 do have semantic meaning and refer to
    the level of headings" is absolutely right and represents _all_ that
    we can say about <h*> elements (although I don't knwo what <h6> has
    done to offend people). This is as much as the W3C recommendation
    states: Headings have "level" and "level" is equated with
    "importance".

    Note that this does _NOT_ imply "ordering". The ISO HTML standard
    additionally imposes ordering, but that's an addition and extension to
    the W3C recommendation, not IMHO a wise or welcome change, simply
    because it is a change.

    So as you cited "level" and Richard discussed "ordering", it is wrong
    to apply the level definition to his comment on order. He's not
    actually wrong here.

    Imposing order on HTML headings could easily have been done by the
    W3C, but it wasn't. They are therefore not ordered and it is wrong for
    any comment on a "web page" to claim that they should be. If some
    organisation wants to impose additional constraints on its own pages,
    to require ordering, then they're welcome to do so. Their constraint
    doesn't apply to my pages though.

    Jukka's statement, "the order h3, h5, h4 is screwed." is wrong,
    because he's exceeding the applicable scope of the extra constraint
    he's applying. It's a useful constraint to apply, when you want it,
    and he's more than welcome to do it on his pages. However this doesn't
    rule out some other corner of the web where such an ordering is
    meaningful and sensible - the W3C certainly didn't rule it out, so we
    shouldn't either. No, I don't know why you'd want this, but I know
    it's a good thing not to forbid such things simply because I can't
    think of a use for them.


    To restore balance to the universe, Richard then posted "<h1> purely
    for looks" where he _is_ incorrect, thus conserving the necessary
    level of stupidity in his postings.
     
    Andy Dingley, May 20, 2008
    #13
  14. richard wrote:
    > On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"
    > <> wrote:
    >
    >> Scripsit :
    >>
    >>> print " <h3>" . $row->itdate . "</h3>";
    >>> print " <h5>" . $row->itname . "</h5>";
    >>> print " <h4>" . $row->itcomments ."</h4>";

    >> That's semantically all wrong, since those pieces of texts are not
    >> headings. A heading is a heading for something; but you have no copy
    >> text.
    >>
    >> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >> level heading immediately after a 3rd level heading?
    >>

    >
    > The so called "order" of headers usage is a myth.
    > The tag is merely intended for displaying text in a certain fixed
    > style.


    You are completely misinformed on this subject.

    > So if one wanted to display <h1> then an <h5> right below or
    > above, it makes no difference.
    >
    > If I want to display an <h5> then an <h1> purely for looks, that's my
    > business.


    It's also your business if you want to wear mismatched socks or shoes or
    wear a bra outside of your shirt. That doesn't mean you should be
    advising other people to do so or imply that it's the correct way to do
    things.
     
    Harlan Messinger, May 20, 2008
    #14
  15. richard wrote:
    > On Mon, 19 May 2008 12:29:27 -0400, "Jonathan N. Little"
    > <> wrote:
    >
    >> richard wrote:
    >>> On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"
    >>>> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >>>> level heading immediately after a 3rd level heading?
    >>>>
    >>> The so called "order" of headers usage is a myth.
    >>> The tag is merely intended for displaying text in a certain fixed
    >>> style. So if one wanted to display <h1> then an <h5> right below or
    >>> above, it makes no difference.
    >>>
    >>> If I want to display an <h5> then an <h1> purely for looks, that's my
    >>> business.
    >>>

    >> Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    >> have semantic meaning and refer to the level of headings within the
    >> structure of a document. If you wish different size text then style it.
    >>
    >> /* some classes for styling */
    >> .date{ font-size: 1.5em; }
    >> .name { font-size: 1.2em; }
    >> .comments{ font-size: 1.0em; }
    >>
    >> example:
    >>
    >> <div class="date"><?php echo $row->itdate; ?></div>

    >
    >
    > Which is what the h tags were designed to do in the first place.


    "In the first place" it wasn't even assumed that people would be reading
    HTML documents on a platform that had proportional fonts or variable
    font sizes. The purpose of most tags was to define the *structure* of
    the document.

    > Act as a shortcut to styling. Which were in use well before CSS came
    > around. So if I can do the same thing in CSS then why have h tags at
    > all?


    That's what people *did*, and it was a disaster. In particular, how can
    you use different headings for "styling" (without the use of CSS) when
    each browser is free to display each heading level however it wants to?
     
    Harlan Messinger, May 20, 2008
    #15
  16. Andy Dingley wrote:
    > On 19 May, 17:29, "Jonathan N. Little" <> wrote:
    >> richard wrote:
    >>> On Mon, 19 May 2008 17:03:23 +0300, "Jukka K. Korpela"
    >>>> Moreover, the order h3, h5, h4 is screwed. How could you have a 5th
    >>>> level heading immediately after a 3rd level heading?

    >
    >>> The so called "order" of headers usage is a myth.

    >
    >
    >> Please disregard, the previous post it is absolutely incorrect. H1-H5 do
    >> have semantic meaning and refer to the level of headings within the
    >> structure of a document. If you wish different size text then style it.

    >
    > Richard isn't _absolutely_ incorrect here (and twice a day he knows
    > what time it is).
    >
    > I would even go so far as to say that he's right and Jukka is wrong.
    >
    > To look at your point, "H1-H5 do have semantic meaning and refer to
    > the level of headings" is absolutely right and represents _all_ that
    > we can say about <h*> elements (although I don't knwo what <h6> has
    > done to offend people). This is as much as the W3C recommendation
    > states: Headings have "level" and "level" is equated with
    > "importance".
    >
    > Note that this does _NOT_ imply "ordering".


    It's at least understood by anyone who knows a priori what headings are,
    what they're for, and what is meant by the concept of different heading
    levels. Sensible people will presumably not mark up the structure of
    their documents in illogical ways, as that would be self-defeating.

    > Imposing order on HTML headings could easily have been done by the
    > W3C, but it wasn't.


    Maybe they thought it was obvious from what they did say. I'd thought so.
     
    Harlan Messinger, May 20, 2008
    #16
  17. Bergamot Guest

    Andy Dingley wrote:
    >
    > Richard then posted "<h1> purely
    > for looks" where he _is_ incorrect, thus conserving the necessary
    > level of stupidity in his postings.


    LOL

    --
    Berg
     
    Bergamot, May 20, 2008
    #17
  18. Andy Dingley Guest

    On 20 May, 16:02, Harlan Messinger <>
    wrote:

    > > Note that this does _NOT_ imply "ordering".

    >
    > It's at least understood by anyone who knows a priori what headings are,


    Of course it is, but only if we permit "a priori" information to have
    an influence here. That's a very bad idea for protocol
    specifications! Judge conformity based on what the recommendation
    _actually_ says, not on what we'd like it to mean.

    > Sensible people will


    ....vary widely in their context-dependent interpretation of
    "sensible".

    > presumably not mark up the structure of
    > their documents in illogical ways, as that would be self-defeating.


    Of course they won't, but what's "logic" here? It's context-
    sensitive, because the scope of application of web markup is hugely
    broad.

    It's really not that hard to define a list (maybe "towns and villages
    in alphabetical order"), to equate "level" with "city/town/village"
    and to place the community's name within an appropriate <h*> according
    to this level. Now generate a HTML page that matches these
    constraints:- <h*> ordering will be all over the place. Yet because we
    interpret <h*> as no more than "level" or "importance", this is a
    perfectly logical, valid and conformant web page. We should not rule
    it out because "the ordering is wrong"


    > > Imposing order on HTML headings could easily have been done by the
    > > W3C, but it wasn't.

    >
    > Maybe they thought it was obvious from what they did say. I'd thought so.


    What they also said was, "Some people consider skipping heading levels
    to be bad practice.", so they obviously considered it. However this is
    merely in one of the informative notes (yes, _some_ people do consider
    ordering to be a requirement), so it's not part of the recommendation.
    Nor can I construe any interpretation onto the normative rec and the
    informative note that requires or recommends that I should do the
    same.

    Enforcing ordering is a practice that some (Jukka) follow and others
    (Richard) don't. The W3C rec doesn't require authors to do either, or
    even to choose one and stick with it.
     
    Andy Dingley, May 20, 2008
    #18
  19. Scripsit Andy Dingley:

    > What they also said was, "Some people consider skipping heading levels
    > to be bad practice.", so they obviously considered it.


    Not really; they just expressed some older HTML principles poorly.

    > Nor can I construe any interpretation onto the normative rec and the
    > informative note that requires or recommends that I should do the
    > same.


    Normative rec? It's a recommendation issued by an industry consortium,
    so if you want to play the game of normativeness, check _the_
    international _standard_ on HTML. It's an exercise in futility, but it's
    the standard (despite my efforts to prevent that nonsense years ago).

    What matters is common sense, structural design principles, and the
    descriptions of heading element semantics. Any statement about
    "importance" and vague statements about "some people" are best
    forgotten.

    > Enforcing ordering is a practice that some (Jukka) follow and others
    > (Richard) don't.


    Of course, but that doesn't say much. You should add that one of these
    practices makes sense and the other one is clueless. It is left as an
    exercise to figure out which is which. You are allowed to check past
    postings by named persons to see whether they make sense in general.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, May 20, 2008
    #19
  20. C A Upsdell Guest

    Andy Dingley wrote:
    > Then of the two, I'd have to side with Richard. Requiring ordering on
    > <h*> is assuming too much about HTML and limiting it to too narrow a
    > scope.


    But ignoring ordering is understanding too little about HTML and
    weakening its scope.

    Let us not forget, however, that the OP was using header tags to obtain
    the styling he wanted, not to suggest any hierarchy, and *this* I think
    is inarguably foolish.
     
    C A Upsdell, May 21, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raj Mudaliar
    Replies:
    0
    Views:
    2,294
    Raj Mudaliar
    Jul 14, 2003
  2. =?Utf-8?B?Um9za28=?=

    DataGrid displaying line breaks in bound column

    =?Utf-8?B?Um9za28=?=, Feb 9, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    4,344
    CraigPaardekooper
    Dec 20, 2011
  3. bernadou

    Force multi line field value to output with line breaks?

    bernadou, Jan 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    371
    bernadou
    Jan 23, 2006
  4. RH
    Replies:
    2
    Views:
    175
  5. Marek Stepanek
    Replies:
    12
    Views:
    425
    Peter J. Holzer
    Sep 2, 2006
Loading...

Share This Page