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.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 22nd, 2007, 23:37
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 23rd, 2007, 11:53
Elite Veteran
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 23rd, 2007, 12:02
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 23rd, 2007, 12:04
Elite Veteran
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 23rd, 2007, 12:09
Highly Reputable Member
Join Date: Jun 2007
Location: Canterbury
Age: 20
Posts: 726
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 23rd, 2007, 12:17
Elite Veteran
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!)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Aug 23rd, 2007, 12:24
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Aug 23rd, 2007, 12:29
Highly Reputable Member
Join Date: Jun 2007
Location: Canterbury
Age: 20
Posts: 726
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Aug 24th, 2007, 16:46
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Aug 24th, 2007, 16:47
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Aug 24th, 2007, 17:17
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Aug 24th, 2007, 17:20
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Aug 24th, 2007, 19:14
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Aug 24th, 2007, 19:29
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: blog structure

Probably longtext but I'm no expert, really.

Pete.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Aug 24th, 2007, 19:41
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Aug 24th, 2007, 19:50
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Aug 24th, 2007, 19:52
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old Aug 24th, 2007, 20:03
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old Aug 24th, 2007, 20:09
Most Reputable Member
Join Date: May 2006
Location: North West, UK
Age: 22
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'&nb