blog structure

This is a discussion on "blog structure" within the PHP Forum section. This forum, and the thread "blog structure are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 22nd, 2007, 23:37
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Smile blog structure

I'm looking to making my own blog
i don't want to use someone elses code because i want to learn how to do it myself and updates and new features would be very confusing.
so this is my quesyion.
basically, how are the structured in general.
like are entries in an external file and are included using an ssi.
or are they stored in a database.
also how do i do permalinks.
and how do you access a certain entry,
like:
blog.com/blog.php?article=1
or
blog.com/blog/articles/1

Thanks
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote

  #2 (permalink)  
Old Aug 23rd, 2007, 11:53
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Everything is in a database.

You should have a table for you blog entries, one for the categories and one for the comments.

To access entries you would do the ?articleid=1 and then query the database with that.
Reply With Quote
  #3 (permalink)  
Old Aug 23rd, 2007, 12:02
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

okay so say i have a database called blog
with two tables called categories and comments.
but what columns would they have?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #4 (permalink)  
Old Aug 23rd, 2007, 12:04
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

You have a database called blog with 3 tables called blogs, categories and comments

Let's start with the blog table ... what do you think you should have in there?
Reply With Quote
  #5 (permalink)  
Old Aug 23rd, 2007, 12:09
1840dsgn's Avatar
SuperMember

SuperMember
Join Date: Jun 2007
Location: Canterbury
Age: 19
Posts: 717
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

posts: title, timestamp, id, entry, category etc.

categories: category id, category name, description

comments: user id, comment, timestamp

user: user id, name, email, url

etc.

Its called database design, you need to think of every piece of information tyour going to need and organise it within the database so it can all link together without causing duplicates. try a search on database normalisatiopn...see what you get.

In the small brainstorma above when a user signs up thier details go into user table, when they comment their comment goes into the cooments table with their user id.

When we wanna display the comment we grab the user id, and use the user id to query to usert table to get the users info and sisplay it aloing with the comment.

This prevents duplicate data. if you didn't split it into user and coomments your comments table would probably be something like: username, url, emal, comment, timestamp...etc.

And if the same user commented 20 times their detyails would be duplicated each time.

By spliting it there is no duplication.
Reply With Quote
  #6 (permalink)  
Old Aug 23rd, 2007, 12:17
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Quote:
Originally Posted by 1840dsgn View Post
posts: title, timestamp, id, entry, category etc.

categories: category id, category name, description

comments: user id, comment, timestamp

user: user id, name, email, url

etc.
ARGH!!!!! SO much for getting people to try and figure this out by themselves (with a little guidance!)
Reply With Quote
  #7 (permalink)  
Old Aug 23rd, 2007, 12:24
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Remember too this is about content management. If one day you decide you want add images or maybe a recipe to a post don't just put an image in that post or type that recipe up into the blog post window. The reason for this is that say a few months down the line you want to be able to search through all of your recipes or all of you photos then you will struggle whereas if it is a totally separate section then the possibilities are much better. All you o then is relate that image or to a particular blog entry.

This all may sound a bit much at first but you need to understand the idea behind content management. If you do it right it will be completely scalable and expandable which is what you want really.

Pete.
Reply With Quote
  #8 (permalink)  
Old Aug 23rd, 2007, 12:29
1840dsgn's Avatar
SuperMember

SuperMember
Join Date: Jun 2007
Location: Canterbury
Age: 19
Posts: 717
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Quote:
ARGH!!!!! SO much for getting people to try and figure this out by themselves (with a little guidance!)
yea but they're not definitiver ansswers liker Pete said. you wouldn't get too fasr using what i posted. they're examples opf what might be in each table and examples i used to explain normalisation.

theres still a lot of work to do. I'm not gonna tell people how. I had to learn it so everyone else can as well.

Sorry I'm in a bad mood lol.
Reply With Quote
  #9 (permalink)  
Old Aug 24th, 2007, 16:46
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Smile Re: blog structure

Quote:
Originally Posted by pa007 View Post
Remember too this is about content management. If one day you decide you want add images or maybe a recipe to a post don't just put an image in that post or type that recipe up into the blog post window.
Pete.
that's not too hard is it? to add an image I'd just add a column wouldn't I?
though for editingm, I guess I'd need to make some system where i can edit the post in textarea form or something I'm guessing?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #10 (permalink)  
Old Aug 24th, 2007, 16:47
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

Quote:
Originally Posted by 1840dsgn View Post
yea but they're not definitiver ansswers liker Pete said. you wouldn't get too fasr using what i posted. they're examples opf what might be in each table and examples i used to explain normalisation.

theres still a lot of work to do. I'm not gonna tell people how. I had to learn it so everyone else can as well.

Sorry I'm in a bad mood lol.
It doesn't really matter for this one as pao007 said I need to make sure i have everything i need to save the hassle.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #11 (permalink)  
Old Aug 24th, 2007, 17:17
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Well you could just add another column but ideally that should be in its own table with all its own data such as when it was taken, when it was uploaded, what its of, etc. This way if you wanted a really snazzy image gallery in the future it would be very simple as the data is isolated. By just adding a column you reduce your options for the future and you reduce the usefulness of that image.

Pete.
Reply With Quote
  #12 (permalink)  
Old Aug 24th, 2007, 17:20
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

okay
well if i don't go out on the town tonight.
I'll start
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #13 (permalink)  
Old Aug 24th, 2007, 19:14
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

hey what should my entries column format thing be?
I'm on about the thing which says how many letters can be in each row etc.
thanks
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #14 (permalink)  
Old Aug 24th, 2007, 19:29
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Probably longtext but I'm no expert, really.

Pete.
Reply With Quote
  #15 (permalink)  
Old Aug 24th, 2007, 19:41
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

Yeah I think so
Oh and could someone tell me what BLOB is?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #16 (permalink)  
Old Aug 24th, 2007, 19:50
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

And what should the date column be?
I want to insert into it using the CURDATE command.
thanks
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #17 (permalink)  
Old Aug 24th, 2007, 19:52
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Well it's a number so int which I assume means integer (whole number).

Pete.
Reply With Quote
  #18 (permalink)  
Old Aug 24th, 2007, 20:03
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

i can't get this to work :s
Code: Select all
create table entries (id MEDIUMINT NOT NULL AUTO_INCREMENT, title VARCHAR(100), image VARCHAR(100), entry LONGTEXT, category VARCHAR(50), date DATE);
I get "incorrect table definition; there can only be one auto column and it must be defined as a key"

eh ?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #19 (permalink)  
Old Aug 24th, 2007, 20:09
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

This is how I would create my DB for a blog, this is pretty simple but the principles are there:

PHP: Select all

 <?php

mysql_connect 
('localhost''username''password') ;
mysql_select_db ('db');

$sql "CREATE TABLE blog_entries (
  id int(20) NOT NULL auto_increment,
  timestamp int(20) NOT NULL,
  title varchar(255) NOT NULL,
  entry longtext NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY id (id)
)"
;

$result mysql_query($sql) or print ("Can't create the table 'blog_entries' in the database.<br />" $sql "<br />" mysql_error());

mysql_close();
?>
You see we have our id as our primary and unique key. This is how you would call those entries from the db. The other fields are self-explanatory.

Pete.
Reply With Quote
  #20 (permalink)  
Old Aug 25th, 2007, 00:38
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: blog structure

Thanks pete I'll try that now
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Tags
blog

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Frame structure WLQ JavaScript Forum 1 Oct 8th, 2007 09:56
Help with website structure irinag Starting Out 3 Apr 24th, 2007 18:43
table-like structure dscanlon Web Page Design 4 Jun 27th, 2006 15:10


All times are GMT. The time now is 22:16.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43