Log in

View Full Version : Displaying Posts Stored In Database


TheWolverine
01-01-2005, 11:04 PM
Hi all,

I'm currently writing a front-end website to accompany my forums and I've hit a metaphorical brick wall. The problem is that posts that are created using vBulletin when stored in the db don't contain the html formatting tags, in particular for paragraphing. I've searched through the source files to see how vBulletin goes about reading these posts from the db and converting them correctly with all the paragraphs intact but I can't for the life of me figure out how it's done. Basically instead of there being <p> or <br /> tags stored along with the posts in the db there are simply lines in between the text. I don't know how to parse this though into paragraphs when I display the posts on the website though in HTML. Here's an example article of how it's stored in the db in case you don't know what I'm on about:

This is the fifth and final article I am posting right now for testing purposes. What should happen is that all of the 5 articles that have been posted should appear on the website with the alternating colour scheme working as well. I haven't tested the length of an article yet, but I've got to somehow only post a certain number of words of the article so that the layout isn't messed up.

This is the fifth and final article I am posting right now for testing purposes. What should happen is that all of the 5 articles that have been posted should appear on the website with the alternating colour scheme working as well. I haven't tested the length of an article yet, but I've got to somehow only post a certain number of words of the article so that the layout isn't messed up.


This is exactly how it is stored in my database now. My problem is parsing the test as two separate paragraphs. When I retreive the data from the db it grabs it as continuous text and I don't know what the delimitation is between the two paragraphs that I could use to split them up. I hope that's clear enough. Bit difficult to explain. The only way it's working now is if the article is for instance entered originally with the HTML formatting included i.e.

This is the fifth and final article I am posting right now for testing purposes. What should happen is that all of the 5 articles that have been posted should appear on the website with the alternating colour scheme working as well. I haven't tested the length of an article yet, but I've got to somehow only post a certain number of words of the article so that the layout isn't messed up.
<br /><br />
This is the fifth and final article I am posting right now for testing purposes. What should happen is that all of the 5 articles that have been posted should appear on the website with the alternating colour scheme working as well. I haven't tested the length of an article yet, but I've got to somehow only post a certain number of words of the article so that the layout isn't messed up.


Since this formatting is done by vBulletin when the user enters the post in the editor I don't know what to take as the reference point to differentiate between the different paragraphs.

Anyhow assistance would be helpful. I'm still fairly new to vB so go easy on me ;)

Thanks in advance

The Wolverine :D

darnoldy
01-01-2005, 11:45 PM
I don't know how to parse this though into paragraphs when I display the posts on the website though in HTML.

Those lines *should be* produced produced by either carriage returns or "carriage reurn/line feed" pairs. You can search on those. As I remember, they are ascii 10 & 13. If you have a text editor that will display white space characters, you should be able to check.

--don

TheWolverine
01-02-2005, 08:26 AM
Ummmm so how would I do a string search for those characters? Cause when I query the db to extract the post as follows and echo the contents of the articlepost table entry it just shows continuous text:

$query_article_table = "SELECT postusername, postbody, posttitle, postdateline, sportscatid FROM articlepost, article WHERE postid=".$postid;
$query_article = mysql_query($query_article_table, $onesports);
$article = mysql_fetch_object($query_article);
$username = $article->postusername;
$postbody = $article->postbody;
$title = $article->posttitle;
$dateline = $article->postdateline;
$sportscat = $article->sportscatid;
echo $postbody;

Resulting in:

Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.

To indicate where there are paragraphs since it's a little hard to spot I added the dummy text formatting tags and [center1]. As you can see there should be a new paragraph going from to for instance but there is simply a normal blank space between these two tags, just like between any of the words. My problem is I don't know how to delimit the text so that I can somehow split the echoed text back into its original paragraphs.

For reference sake this is how the paragraphs should look like, like I entered them through the forum:

Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.

Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.

Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.

[CENTER]Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum. Lorem ipsum. Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.Lorem ipsum.

This is directly copy-pasted from the showthread.php parsing.

The Wolverine :D

TheWolverine
01-03-2005, 09:38 AM
No one with a suggestion? It looks like that only text formatting where no tag is added is for paragraphs. Everything else tags are added so it's easy enough to parse the formatting. I have no clue how to go about splitting the text into paragraphs tho.

The Wolverine :D