Jump to content

Large Text Best Format


jiveturkey

Recommended Posts

Hello All

 

First post here, so sorry if this is a common request.

 

I am trying to build a website which will have pages that include long bits of descriptive text such as describing the history of places of interest in Japan.  In the database I have set this up as a text type column.  If I want to format the various paragraphs in the text as html paragraphs how should I go about it?  It is possible to break up a long piece of text using PHP (via a loop) and add <p> tags or should I add the p tags to the data inserted into the data base.  I don't really like the last option as its not re-useable.

 

The other option is to make a separate table for the text and split this into paragraphs but this idea seems like a non-starter for me.

 

I hope you can understand this - and if you can I'd appreciate any help

 

J

 

 

Link to comment
Share on other sites

Store paragraphs normally like a text file with paragraphs seperated by two newlines and then output the paragraph something like this:

 

<?php
$result = mysql_query("SELECT history FROM repository WHERE id = 1");

if (mysql_num_rows($result) && (list($record['history']) = mysql_fetch_row($result))
{
     $record['history'] = "<P>" . str_replace("\n\n", "</P><P>", $record['history']) . "</P>";

     print $record['history'];
}
?>

 

The above would not be appropriate for complex formatting, like colours and type styles... user defined code blocks like forums use may be more appropriate if more complex formatting is required.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.