Check out my NEW training website for front-end web developers, FrontendMasters.com

Create a Blog from Scratch

May 05, 2007

Note on June 23, 2008: The post you are reading is years old, but shows the trail of the beginnings of MarcGrabanski.com. Thank you for reading!

Without much prior PHP knowledge, I managed to program this blog in less than a week. Here is how I did it. Note: This is an overview and not actual code examples.

1. First, I went through Code Grrl’s Build a Blog Tutorials

Sure, I could have stopped there but I really didn’t like how the blog was programmed. I like this tutorial though because I dug through the code and learned basic PHP, but I wanted much more functionality.

2. I wanted clean URLs so I found Making clean URLs with Apache

I customized the url so I can add keywords inside it if I want. I love these clean URLs. Apache also has documentation on mod_rewrite.

3. Then I added user authentication

This was the most basic, yet effective login script I found. Of course I modded it to make it a little more secure.

4. *I rewrote the code to use Object Oriented PHP *

My blog was basically built but I didn’t like how the code looked. I thought PHP looked horrible until I ran into some object oriented code. Makes things look much nicer.

5. Created Tag Cloud Navigation

I started with ByteMyCode’s Tag Cloud code and then moved to selecting from the database with the"LIKE"MySQL commmand.

$sql = "SELECT * FROM php_blog WHERE tags LIKE$tagORDER BY timestamp DESC";

I also had to count the tags so I used the array_count_values PHP function.

$tags = array_count_values($DBtags); // a very useful function to count the tags!

Wow gotta love those tags!

6. Adding More Features

I added an image uploader to my admin page, RSS 2.0 and many minor tweaks until I had my *very own customized blog built from scratch!

Some functions I found very useful on php.net:

@list() split() htmlspecialchars() str_replace() explode() include(dirname(__FILE__)

I now have my own custom blog! You can too! I heavily modified each example and made them my own. It feels so nice to have a custom blog!

Like this article? You'll like my NEW training website for front-end web developers!

Video workshops on jQuery, JavaScript, HTML5, web performance and more.
Upgrade your front-end developer skills!

38 comments

#1. leo on March 23, 2008

mind to give out your source code?

#2. radman on April 07, 2008

Thank you Marc,
This article really helping for me.
I think we don’t need to know the source code, to build our own blog.
With this instruction, we can do it without have to know the source code.

#3. Farha on April 09, 2009

Thanks, for guiding.
You give a man a fish you feed him once. You teach him to fish and you feed him a lifetime

#4. Ivan Torres on July 26, 2009

Great post and site!

How do u make it more secure? Own knowledge or tutorial site?

#5. Daniel on October 30, 2009

I’d love to see your Cake code for getting the Tag Cloud to work – I’m trying to get one working on my site, but having all sorts of trouble. I’d love to follow the example that you’ve demonstrated here, but I’m just not good enough to understand how to make it all work in Cake.

#6. SplitFive on November 12, 2009

Nice post.

#7. ghprod on November 13, 2009

Hi,

can u share with your source code?

thanks a lot :)

regards

#8. chris on February 14, 2010

this would be a great help, I’m making a class project, a blog site, and I just have a little knowledge in PHP and MySQL, I just installed XAMPP on my desktop, and I’ve been looking for tutorials for some days now… I really need some help.

#9. yourname on June 25, 2010

its a good tutorial thanks

#10. z on July 15, 2010

nice tut

#11. z on July 15, 2010

nice tut

#12. vakshika on July 28, 2010

i have learned PHP MYSQL from SPcits institutes.With the help of live project training they provide it helped me very much to clear my concept

#13. buce on August 24, 2010

2 nice

#14. Wordpress Development India on September 21, 2010

Nice article. Thanks, for guiding.

#15. george on September 24, 2010

ok!

#16. Jordon on October 05, 2010

his should be all we need to make our blogs? Please do email me back on this topic.

#17. Meghann on October 13, 2010

very interesting thanks for puting this on your website it has helped tons

#18. ian on October 27, 2010

Nice list. I will use it in future. Thanks for the efforts to make this list!Nice list. I will use it in future. Thanks for the efforts to make this list!

#19. Dell used laptops on November 02, 2010

The blog provides helpful information regarding the topic and it also gives a vast knowledge as well which helps us in our studies and in practical life.

#20. collegecoder on November 06, 2010

Hi Marc
Im trying to do a college project with a blog and struggling… any chance you can help out with the code?
Would really appreciate it

#21. Zeth on November 25, 2010

Wow, you went through quite a lot to build a blog. Great job. You seem like an expert on in the field – what do you prefer: Joomla or Wordpress? I’ve only used Wordpress, but I’ve heard lots of good things about Joomla. Is it worth looking into?

#22. Marc Grabanski on November 25, 2010

WordPress

#23. hopeto on December 30, 2010

thanks, this has helped me on my way jack

#24. siphiwe on January 07, 2011

nice tut, can i have your code pls

#25. Zeth on February 03, 2011

Wordpress, you say Marc? But why? I mean, since I’ve only used Wordpress, then I can’t say that I disagree :D.

#26. Vinayak on February 08, 2011

I don’t need the source code. He inspired me and that’s good enough.
Good job dude! I’m gonna try it.
Thanks a lot for this post. :)

#27. Dora on February 14, 2011

nice tutorial.
do u have the source code?
btw, i wanna see how its look like :)

thx!

#28. Benedict on May 06, 2011

im a beginner web developer can please teach me how to create a blog page.. thankz

#29. jigz on May 06, 2011

can you please send me your blog script if you dont mind

#30. arist on June 19, 2011

learned

#31. winracer on September 19, 2011

would you share sourse code?

#32. james on October 08, 2011

hey… you are good men

#33. aja on December 28, 2011

thnks

#34. Dicky Syaputra on January 02, 2012

trims for your sharing, but i confuse about how to show gravatar on comment ? :(

#35. Taran on September 18, 2012

Its a great article.Thanks a lot for sharing useful post.

#36. basit on December 18, 2012

Awsum ;)

#37. Cc on January 14, 2013

Can you just add a blog as a column on part of a web site?

#38. Leki on March 12, 2013

Awesome

Leave a comment

Comment in textile images by gravatar