📅 Week 12 - Day 1: Blog Project Planning

Monday | Duration: 3 hours | Final Project Begins! 🎉

🎯 Learning Objectives

📝 Project Overview: Simple Blog System

What We're Building:

A complete blog application where users can create, view, edit, and delete blog posts. This project combines everything you've learned: HTML, CSS, PHP, and MySQL!

✨ Project Features

📰 View Posts

Display all blog posts on homepage with title, excerpt, author, and date

➕ Create Post

Form to add new blog posts with title, content, and author

👁️ View Single Post

Read full blog post with all details

✏️ Edit Post

Update existing blog posts

🗑️ Delete Post

Remove unwanted blog posts

🔍 Search

Find posts by title or content

🗄️ Database Schema

Posts Table Structure:

Column Data Type Description
id INT AUTO_INCREMENT PRIMARY KEY Unique post ID
title VARCHAR(200) NOT NULL Post title
content TEXT NOT NULL Full post content
author VARCHAR(100) NOT NULL Author name
category VARCHAR(50) Post category (optional)
views INT DEFAULT 0 View count
created_at DATETIME DEFAULT CURRENT_TIMESTAMP Creation date/time
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP Last update date/time

SQL to Create Database and Table:

-- 1. Create database CREATE DATABASE blog_db; USE blog_db; -- 2. Create posts table CREATE TABLE posts ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(200) NOT NULL, content TEXT NOT NULL, author VARCHAR(100) NOT NULL, category VARCHAR(50), views INT DEFAULT 0, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); -- 3. Insert sample data for testing INSERT INTO posts (title, content, author, category) VALUES ('Welcome to My Blog', 'This is my first blog post. I am excited to share my thoughts and experiences with you all!', 'Ahmad Ibrahim', 'General'), ('Learning PHP and MySQL', 'Today I learned how to connect PHP with MySQL. It opens up so many possibilities for web development. I can now create dynamic websites that interact with databases!', 'Fatima Yusuf', 'Technology'), ('The Power of Web Development', 'Web development has changed my life. From HTML to CSS to JavaScript and now PHP, each step has been rewarding.', 'Ibrahim Musa', 'Career'), ('Building My First CRUD App', 'CRUD operations are the foundation of most web applications. Today I built my first complete CRUD system!', 'Aisha Hassan', 'Technology');

📁 Project File Structure

blog-project/ │ ├── config/ │ └── database.php # Database connection │ ├── includes/ │ ├── header.php # Header component │ ├── footer.php # Footer component │ └── nav.php # Navigation menu │ ├── css/ │ └── style.css # Main stylesheet │ ├── index.php # Homepage (list all posts) ├── view_post.php # View single post ├── create_post.php # Create new post ├── edit_post.php # Edit existing post ├── delete_post.php # Delete post └── search.php # Search posts

🎨 Styling Plan

/* Basic color scheme */ --primary-color: #f5576c; --secondary-color: #f093fb; --text-color: #333; --background: #f9f9f9; --card-background: #fff; /* Layout */ - Responsive design - Grid layout for post cards - Clean, modern interface - Mobile-friendly navigation

📋 Project Checklist

Task Day Status
Database setup Day 1 ☐ To Do
File structure creation Day 1 ☐ To Do
Database connection file Day 1 ☐ To Do
Header/Footer components Day 1 ☐ To Do
Homepage (view posts) Day 2 ☐ To Do
View single post Day 2 ☐ To Do
Create new post Day 2 ☐ To Do
Edit post Day 3 ☐ To Do
Delete post Day 3 ☐ To Do
Search functionality Day 3 ☐ To Do
Final testing & polish Day 3 ☐ To Do

💻 Setting Up Today

Step 1: Create Database

  1. Open phpMyAdmin
  2. Create database blog_db
  3. Run the SQL above to create posts table
  4. Insert sample data

Step 2: Create Project Folder

  1. In C:\xampp\htdocs\ create folder blog-project
  2. Create subfolders: config, includes, css

Step 3: Database Connection (config/database.php)

<?php // config/database.php // Database configuration define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); define('DB_NAME', 'blog_db'); // Create connection $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // Set charset mysqli_set_charset($conn, "utf8mb4"); ?>

Step 4: Create Basic CSS (css/style.css)

/* css/style.css */ * { margin: 0; padding: 0; box-sizing: border-box; } :root { --primary: #f5576c; --secondary: #f093fb; --dark: #333; --light: #f9f9f9; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; background: var(--light); color: var(--dark); } .container { max-width: 1200px; margin: 0 auto; padding: 20px; } /* Header */ header { background: linear-gradient(135deg, var(--secondary), var(--primary)); color: white; padding: 30px 0; margin-bottom: 30px; } header h1 { font-size: 2.5rem; text-align: center; } /* Navigation */ nav { background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); margin-bottom: 30px; } nav ul { list-style: none; display: flex; justify-content: center; padding: 0; } nav ul li { margin: 0 15px; } nav ul li a { display: block; padding: 15px 20px; color: var(--dark); text-decoration: none; transition: color 0.3s; } nav ul li a:hover { color: var(--primary); } /* Buttons */ .btn { display: inline-block; padding: 10px 20px; background: var(--primary); color: white; text-decoration: none; border-radius: 5px; border: none; cursor: pointer; transition: background 0.3s; } .btn:hover { background: #d94860; } /* Cards */ .post-card { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); margin-bottom: 20px; } /* Footer */ footer { background: var(--dark); color: white; text-align: center; padding: 20px; margin-top: 50px; }

✏️ Today's Tasks

  1. Create blog_db database with posts table
  2. Insert sample blog posts
  3. Set up project folder structure
  4. Create config/database.php
  5. Create css/style.css
  6. Test database connection

✅ Today's Deliverable

← Previous Week Course Home Next: Day 2 →