Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP text output from a database...

Options
  • 17-05-2007 7:02pm
    #1
    Closed Accounts Posts: 7,097 ✭✭✭


    Hi All,

    I have a PHP database up and running and I can post data into it from one webpage and read data from it using another. The only problem I have is that one or two fields are longtext fields, and they hold a few hundred characters of text. When I output this to a webpage, its reads like this:

    sssssssssssssssddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

    As in it is one long horizontal line of text which doesn't look great on the page.

    Could anyone tell me how to justify this text so it is nice and neat on the page when it is outputted and the text is aligned on both the left & right margins??? Being able to control the width of the column would also help.

    Any help much appreciated!

    Dar.


Comments

  • Registered Users Posts: 5,335 ✭✭✭Cake Fiend


    Well, first of all, PHP isn't a database, and second, this should be on the programming board.

    With that anality out of the way, you could write a function that will take in a string and a maximum line length, and get it to put '<br />'s after every [maximum length] characters, checking first whether [maximum length] characters falls within the middle of a word. Justification would be trickier, but I'd bet that someone out there has written something to do it. I suppose you could add up the number of words in the line, count how many spaces short of a line of [maximum length] the line in question is, then distribute spaces evenly throughout the line.


  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Cake Fiend wrote:
    Well, first of all, PHP isn't a database, and second, this should be on the programming board.

    With that anality out of the way, you could write a function that will take in a string and a maximum line length, and get it to put '<br />'s after every [maximum length] characters, checking first whether [maximum length] characters falls within the middle of a word. Justification would be trickier, but I'd bet that someone out there has written something to do it. I suppose you could add up the number of words in the line, count how many spaces short of a line of [maximum length] the line in question is, then distribute spaces evenly throughout the line.

    Probably a dumb question but why not enclose the outputted text in a div tag and set the width of the div to x amount of px / x cm ?? You can set the justification then either left right or center but if it's one long continuous string that probably won't make much of a difference

    -RD


Advertisement