Text formatting of articles pulled from database??

2003-03-19 Thread Landy Atkinson
I am setting u a simple article storage/retrieval system and have set 
up a MySQL database with a few VARCHAR fields for author, date, 
source and a BLOB field for article.  I have also set up two pages, 
one for editing/adding new articles and a second one for viewing the 
articles.

The adding/deleting page uses a FORM with TEXTAREA to allow 
someone to copy past the text into the article field.  This seems 
to work just fine and if I display the  text back in a FORM 
TEXTAREA field, formatting works as I expect.  Paragraphs are 
separated by a line of white space and the text wraps to the size of 
the TEXTAREA.

I am trying to display the article on a second page which is 
formatted to look nice.  I would like to avoid the borders and fixed 
height (with scroll bars) of the TEXTAREA field and instead put the 
text into an auto height table cell with fixed width=500 so the text 
still wraps nicely on the screen.  I've set up a table with 3 columns 
to allow me to display the title, author, date, etc. nicely at the 
top and then defined a table cell that spans the 3 columns to hold 
the article.

echo TD colspan=\3\ width=\532\P$article/P/TD;

The text displays, but the paragraph breaks are gone and all the text 
is just run together into one long paragraph.

Any suggestions on how to get $article to display and keep the white 
space between paragraphs that it has when displayed in a 
FORMTEXTAREA like

echo td colspan=6textarea name='article' rows='15' 
cols='120'$article/textarea/td;

For an example, see 
http://www.cobblekids.org/Pages/Articles/Article_View4b.php and click 
on an article title.

Thanks,
-Landy
-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


Re: Text formatting of articles pulled from database??

2003-03-19 Thread Stefan Hinz
Landy,

 echo TD colspan=\3\ width=\532\P$article/P/TD;

 The text displays, but the paragraph breaks are gone and all the text 
 is just run together into one long paragraph.

In PHP, you can use nl2br(), like:

echo TD colspan=\3\ width=\532\P.nl2br($article)./P/TD;

This will replace \n (the new-line character that makes that line
break in TEXTAREA) by br/. If you're a maniac (like I am) you can
even do:

echo TD colspan=\3\ width=\532\P
 .str_replace(nl2br($article),br/,/pp
 style=\text-indent:10px\)
 ./P/TD;

Or something similar to that.

Regards,
--
  Stefan Hinz [EMAIL PROTECTED]
  iConnect GmbH http://iConnect.de
  Heesestr. 6, 12169 Berlin (Germany)
  Telefon: +49 30 7970948-0  Fax: +49 30 7970948-3

[filter fodder: sql, mysql, query]


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Re: Text formatting of articles pulled from database??

2003-03-19 Thread Henning Heil
 Landy Atkinson wrote on 19.03.2003 18:14 

...


echo TD colspan=\3\ width=\532\P$article/P/TD;

The text displays, but the paragraph breaks are gone and all the text 
is just run together into one long paragraph.

Any suggestions on how to get $article to display and keep the white 
space between paragraphs that it has when displayed in a 
FORMTEXTAREA like

echo td colspan=6textarea name='article' rows='15' 
cols='120'$article/textarea/td;

For an example, see 
http://www.cobblekids.org/Pages/Articles/Article_View4b.php and click 
on an article title.

Thanks,
-Landy 


Landy,

I think this is far more a php/html than a MySQL problem, I don't 
remember the code exactly but try playing around with the php-function 
htmlspecialchars (or similar) before inserting into DB / echo-ing out 
the article and you'll hopefully find a solution soon.

Rgds,

Henning

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php