473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Format preserving

114 100+
if we are to have news management system in php for our site, how can we preserve the format of the contents. I mean a news can be long enough to have many paragraphs, and sometimes we may need to insert bullets and numbering, and so on..... In this case, when we add news to database, how is the contents given the same format as it is entered so that when we fetch it, the contents are displayed in the same format as entered .
May 27 '08 #1
5 1255
hsriat
1,654 Expert 1GB
A very good example for you is Wikipedia. Open any page on it, and click somewhere on edit. See how are they save the formatting. Its really database friendly (consuming less bytes).

(link)
May 27 '08 #2
Atli
5,058 Expert 4TB
If you save it into the database exactly as it was typed, including all white-space characters like the new-line char and the tab char you can print it in a <pre> tag or in a div with the 'white-space: pre' style set.
That way all the paragraphs and such will be preserved.

For numbering and bullets and other sort of formatting, you could try using BBCode.
May 27 '08 #3
raaman rai
114 100+
thanks buddy, it was great but i must tell you that i couldnot configure the BBCode Parser. Infact i am using WAMP5 version 2 and i think i did install PEAR with the assistance from some tutorials. But unfortunately i couldnot configure the BBCode Parser as i could not find a proper help or tutorials. So, would you mind helping me how to do it?
May 29 '08 #4
Atli
5,058 Expert 4TB
I'm not sure about the PEAR package. I never really got into that stuff.

But as far as I know, you should only have to install it, by typing something like this into a cmd.exe window:
Expand|Select|Wrap|Line Numbers
  1.  pear install HTML_BBCodeParser 
And then you should be able to use it, like:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Load and create object
  3. require_once('HTML/BBCodeParser.php');
  4. $parser = new HTML_BBCodeParser();
  5.  
  6. // Parse some text
  7. $parser->setText($_POST['SomeString']);
  8. $parser->parse();
  9.  
  10. // Print the parsed text
  11. echo $parser->getParsed(); 
  12. ?>
  13.  
May 30 '08 #5
raaman rai
114 100+
hey you made me fly, it was awesome as it worked. Thanks ya man but i am not sure if this setup is managed by the ISP itself (who is hosting the web) or it needs to be done by ourselves. Please do me another favour by enlighting me in this issue.
Jun 2 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Karl | last post by:
This might not really be a javascript question, but I'll start with this group. At http://www.gazingus.org/ there is a very nice collapsible menu written using CSS and Javascript >>>> Using...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
1
by: Duncan Muirhead | last post by:
I'm writing a wee utility that applies some simple transforms (eg adds offsets) to some (text file) fields that represent floating point numbers. Simple enough. However I would like to preserve the...
3
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.