Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Creating your own blog

  1. #1
    melkior_inactive Guest

    Default Creating your own blog

    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.

  2. #2
    UK WW ex member is offline Senior Member
    Join Date
    Jan 2007
    Posts
    161

    Default

    Hi Very intersting ,posting here to subscribe the thread and be informed the progress.

    Wishing you good luck

  3. #3
    Bisje's Avatar
    Bisje is offline Senior Member
    Join Date
    Feb 2007
    Posts
    160

    Default

    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 Fotosite to see my pictures.

  4. #4
    Join Date
    Mar 2007
    Posts
    38

    Default

    melkior that is a great idea maybe we can all contribute to this project

  5. #5
    melkior_inactive Guest

    Default

    Well, when the blog is finished anyone can expand it as he sees fit.
    The base idea of this thread is for it to be a tutorial for now.
    But thanks for your offer.

  6. #6
    Join Date
    Mar 2007
    Posts
    38

    Default

    Ok I guess I didn't read very good the first post anyway I'll keep an eye on this thread

  7. #7
    melkior_inactive Guest

    Default Lesson 1 - The Theory

    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.

  8. #8
    melkior_inactive Guest

    Default Lesson 2 - The Database

    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
    );
    So now we have a table named blog ready for our inputs.
    We'll be expanding this database in future tutorials.

  9. #9
    melkior_inactive Guest

    Default Lesson 3 - First PHP code

    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:
    <?php

    $dbuser 
    'username'//database username
    $dbname 'blog'// database name
    $dbpass 'password'//database password
    $dbhost 'localhost'//database host -- usually 'localhost' but best to check with your host

    $sitename 'My Blog'//name of your site

    mysql_connect($dbhost$dbuser$dbpass);
    mysql_select_db($dbname);

    ?>
    We'll include this file in our other files in the next step.

  10. #10
    melkior_inactive Guest

    Default

    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:
    <?php

    include ("config.php");

    ?>

    <HTML>
        <HEAD>
            <TITLE><?php echo $sitename?></TITLE>
        </HEAD>
        <BODY>
            <H1><?php echo $sitename?></H1>
            <?php
            $sql 
    ="SELECT * FROM blog ORDER BY id DESC LIMIT 10";
            
    $result=mysql_query($sql);
            while (
    $record mysql_fetch_object($result)) {
            echo 
    "<dt><b>$record->title</b></dt>";
            echo 
    "<em>$record->date</em>";
            echo 
    "<dd>$record->text</dd>";
            echo 
    "<p></p>";
            }
            
    ?>
        </BODY>
    </HTML>

    <?php

    mysql_close
    ();

    ?>
    We start by including the data from the config file which also manages connecting to the database for us.
    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.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating a custom page in vBulletin
    By melkior_inactive in forum Forum Software
    Replies: 7
    Last Post: 04-28-2012, 08:37 AM
  2. Creating and running a discussion forum
    By temi in forum Webmaster Tips and Tricks
    Replies: 43
    Last Post: 03-29-2009, 03:39 PM
  3. Tips for creating better website
    By temi in forum Webmaster Tips and Tricks
    Replies: 11
    Last Post: 03-21-2008, 12:25 AM
  4. PR4 Real Estate - blog posts for sale - one year old blog
    By stock_post in forum Other Advertisements (Ads spaces such as banner, blogs and articles)
    Replies: 1
    Last Post: 08-23-2007, 07:44 AM
  5. Creating Banners
    By gkd_uk in forum General Webmaster Talk
    Replies: 1
    Last Post: 05-26-2007, 10:36 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124