|
|||
|
OK, did you ever think about creating your own blog?
I know it sounds complicated but it's not. You need a database, and a couple of PHP files to start. The idea of this thread is to create a simple blog step by step. First we'll create a database, a simple backend and a simple CSS style. Later we'll expand all of this, add new functions, effects, enhace the look of the blog and so on. This thread will be updated at least once a week with new functions for the blog until we end up with a completely finished blog application. Once finalized this blog could power your personal blog. I know there are many free blog solutions available on the net and they all have more features than this blog will ever have (unless I get a very large open source development community ), but creating your own blog would give your site a unique look and feel. And this script, once written can be easily modified to act as a CMS.OK, this was the intro. First lesson tomorrow. |
|
||||
|
And I post for exactly the same reason
Looking forward to the first lesson ! Great idea.
__________________
Take a look at Eric's Books Site to know what I read
or at Eric's Boeken Site for the Dutch talking.Add your book-related site to my Books Directory...my First attempt to LBS |
|
|||
|
Well seeing that this thread caused interest I better move along.
Well, first of all, let me tell you that this tutorial will be written for those who have an elementary knowledge of PHP, HTML and MySQL although it's not necessary. I'll try to keep it as simple as possible and you can ask me about the details on any part of this project anyway. OK, a little bit of theory for a start. The logic behind the basic functions of a blog is fairly simple: Each blog consists of 3 parts (2 if you divide them by type). First part is the user interface. In this case it'll be a collection of PHP scripts which will work as a whole to generate the pages for the visitors to view. Second part of the blog is the administration control panel which allows the admin (in this case you) to add new posts, add links to the blogroll and so on. And the final, third part is the database. The database contains all the posts, links and everything else in your blog. These 3 parts interact together and create what we call a blog. The user interface fetches the data from the database and formats it as a webpage, while the admin control panel inserts the data into the database. OK, next post -- some real programming. ![]() |
|
|||
|
Before writing any code we need to design the database cause we really need to know what data we'll be using in the script and also what functions we'll need to create.
We'll start with a simple database - it will use only one table. We don't need too much at first anyway. We'll need a date on the posts, their titles, the text in the post and we'll add an ID for the posts (we'll need that later). So here's the SQL code for creating the table. You can run this query in phpmyadmin after creating the database or import it or whatever suits you. Code:
CREATE TABLE `blog` ( `id` INT( 128 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `date` TIMESTAMP NOT NULL , `title` VARCHAR( 100 ) NOT NULL , `text` TEXT NOT NULL ); We'll be expanding this database in future tutorials. |
|
|||
|
Now that we have a database ready we need something to input the data and something to display the data from the database.
First, what we'll do is create a config.php file. It will include settings for the database connection and some other configuration info. Here's the code: PHP Code:
|
|
|||
|
Well, we have the config file.
We need something that will display our blog. We need to create an index.php file. This is the source code: PHP Code:
After that we switch to HTML to format a normal web page but we include dynamic content. We use the PHP echo statement to write out the name of the site in the header and also in the first line after the opening BODY tag. The name is taken from the $sitename variable in the config.php file. We again switch to PHP in the body section to select all the data from the database, we use a while loop to continue fetching data until we reach the end of the database. We order it by the id stored in the database and it's descending (to show the latest posts first). We're also limiting the selection to 10 entries. The retrieved data is stored in the $record and we can access the parts we need by writing $record->name_of_what_we_need So we write out the data, first the title, than the date and finally the post itself. We format it with a little bit of HTML and that's it. Later today I'll post the source code of the script we'll use to insert data, and set up a live example. |
![]() |
| Bookmarks |
| Webmaster Resources |
| • UK Web Hosting • UK WW SEO Tools • Free site submission • Web Directory |
| Advertisement |
|
| Site Of the Month |
![]() Nominate site of the month |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating and running a discussion forum | temi | Webmaster Tips and Tricks | 39 | 06-19-2008 08:20 AM |
| Tips for creating better website | temi | Webmaster Tips and Tricks | 11 | 03-21-2008 02:25 AM |
| Creating a custom page in vBulletin | melkior_inactive | Forum Software | 3 | 01-18-2008 11:14 AM |
| PR4 Real Estate - blog posts for sale - one year old blog | stock_post | Other Advertisements (Ads spaces such as banner, blogs and articles) | 1 | 08-23-2007 09:44 AM |
| Creating Banners | gkd_uk | General Webmaster Talk | 1 | 05-26-2007 12:36 PM |
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |