Click to See Complete Forum and Search --> : article system
nabeels786
Apr 27th, 2002, 11:32 AM
i want to make a article system with multiple pages, you can submit an article, itll email it to me, and i can add the article in using a page on the site.
the problem is, i dont know how to organize the db for multiple page.
ill have:
name | user_id | article_name | len_pages | ...
the user id is their forums registration id, im using the same scheme
any suggestions?
thanks :)
The Hobo
Apr 27th, 2002, 12:22 PM
Are you using a flat-file database or SQL?
nabeels786
Apr 27th, 2002, 12:25 PM
sql
thexchord
Apr 27th, 2002, 05:45 PM
Originally posted by nabeels786
i want to make a article system with multiple pages, you can submit an article, itll email it to me, and i can add the article in using a page on the site.
the problem is, i dont know how to organize the db for multiple page.
ill have:
name | user_id | article_name | len_pages | ...
the user id is their forums registration id, im using the same scheme
any suggestions?
thanks :)
i don't think i got ur question exactly - but do u want to store multiple page articles in a db and then display them pagewise?
are you storing each page in a separate field/row in which case your prob would be to design the db fields?
or are you storing the entire article in one field and ur prob is to paginate the article?
sorry if i got U confused! but let me know - i think i can help...
nabeels786
Apr 28th, 2002, 11:54 AM
Originally posted by thexchord
i don't think i got ur question exactly - but do u want to store multiple page articles in a db and then display them pagewise?
are you storing each page in a separate field/row in which case your prob would be to design the db fields?
or are you storing the entire article in one field and ur prob is to paginate the article?
sorry if i got U confused! but let me know - i think i can help...
yeah, i want to display each article page by page, but i have to idea how to store it...i dont know whether to store the whole article and paginate the article, or put each page in a seperate key, but there wont be a definate or max number of pages...either is fine. i just need some ideas on how to do it.
i hope that explains it
thanks :)
thexchord
Apr 28th, 2002, 12:48 PM
hi nabeels
i can definitely help u with that. but give me a couple of hrs from now, to post an answer since i m at work!
btw.. i'll be telling u how to design the db so that an article can be any no. of pages, and all pages will be stored in separate rows...
thanks
nabeels786
Apr 28th, 2002, 01:10 PM
ok thanks alot :)
take your time
thexchord
Apr 28th, 2002, 05:24 PM
hi nabeel,
here's what i propose:
Two tables :
tblArticles :
user_id | art_id | art_title
tblArticleContents
art_id | art_pageno | art_content
When a new article is input :
1. Create a new row in the tblArticles table for this article. art_id is an auto_increment field, and art_title can be the name/Title of the article
2. Say the art_id generated for this article, is "aid"
3. Suppose you want each page to show up as 300 words long - make that a constant, say ART_WORDS_PER_PAGE
4. Then for the content that is input for this article, run a loop over the content text, and for each block of text ART_WORDS_PER_PAGE long, make a new row in the tblArticleContents table, putting:
a. art_id = aid
b. art_pageno = the loop counter (starting at 0, or 1, preferable)
c. art_content = the current block read
Get It? Now the article has been divided into several pages, each ART_WORDS_PER_PAGE long. Each row is numbered in the art_pageno field.
Suppose you want page 2 of some article with art_id = 'artidy' by a user 'useridx', then search for 'useridx' in user_id field, and 'artidy' in art_id in tblArticles - you'll get the title.
Now you need the first page of this article - search for art_id = artidy and art_pageno = 0 in tblArticleContents.
I hope that makes things clear. Please let me know if you have any questions. Or if i puked over the problem. ;)
nabeels786
Apr 28th, 2002, 05:37 PM
that sounds perfect
gimme a few days to work something up, got school work to finish :(
thanks alot :)
(btw, you can check out what ive got already, http://fbgforums.jniv.net ;))
thexchord
Apr 28th, 2002, 05:39 PM
ok! keep me posted!
nabeels786
Apr 28th, 2002, 05:43 PM
i will, thanks for the help, i appreciate it :)
cafeenman
May 12th, 2002, 10:51 PM
You'll probably want to do some additional checking. For example, if the last page is less than 1/2 your defined page length, then include it with the last page of your article. In the examples in previous posts (300 words) then if you have 1600 words in the article then it would be 4 pages of 300 words and page 5 would have 400 words.
My other thought is that you should at least end on a paragraph. 300 words will probably end in the middle of a sentance 70% of the time. So you'll want to find the end of the paragraph that includes the 300th word and break the page there.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.