Skip to content
CodeAstrology
Working Hours 9:30 am - 6:30 pm (Sun - Thu)
Contact Us contact@codeastrology.com
CodeAstrology

CodeAstrology

We Develop and Sell WordPress Plugins and Themes

  • Home
  • About
    • Services
    • Company
    • Team
  • Products
    • Premium Products
    • Woo Product Table
    • Min Max Quantity & Step Control
    • UltraAddons
    • Pricing – Add to cart button Changer
  • Blog
  • Contact
  • My Account
    • Support Area
    • Affiliate Area
 0 - $0.00
Get Quote
How to create a blog in PHP and MySQL database
By Saiful Islam

How to create a blog in PHP and MySQL database

This article describes to you how to build a complete blog from PHP and My SQL database. You can create, edit, update and published the PHP and MySQL database. Your Audience can browse blog articles catalog and click on any articles that they want to read.Follow this process. You can quickly learn how to create a blog in PHP and a MySQL database.

Table of Contents

  • Features
  • Woo Product Table Pro
      • The Most Popular Product Table Plugin For WooCommerce
  • Implementation

Features

  • Two types of Users like – Admin & Normal Users are managed by user registration system.
  • The Admin area and public area separated from each other in the blog.
  • The admin user can only log in to admin area and in the general public area the normal user can only logged in.
  • Two types of admin exist in the admin area –
  • Admin:
  • Any post can create, update, published or delete
  • Topic can also create, delete, update or published
  • Admin can also delete, update or view other admin user.
  • Author
  • Author can create, update, and delete only their posts.
  • A particular topic is chosen for each post.
  • Each public post lists with author, features image, date and so on.
special offer for code astrology

Woo Product Table Pro

The Most Popular Product Table Plugin For WooCommerce

Get Special Discount

Implementation

Let’s start coding. Project name complete-blog-php. In our server directory (htdocs or WWW), create a folder named complete-blog-php.  In your choice text editor open this folder like- Sublime Text. Create a subfolder inside it: admin, includes and static.

In this application’s root folder, create a file named index.php               :

Open this folder and paste the following code in it:

<!DOCTYPE html>

<html>

<head>

<!-- Google Fonts -->

<link href="https://fonts.googleapis.com/css?family=Averia+Serif+Libre|Noto+Serif|Tangerine" rel="stylesheet">

<!-- Styling for public area -->

<link rel="stylesheet" href="static/css/public_styling.css">

<meta charset="UTF-8">

<title>LifeBlog | Home </title>

</head>

<body>

<!-- container - wraps whole page -->

<div class="container">

<!-- navbar -->

<div class="navbar">

<div class="logo_div">

<a href="index.php"><h1>LifeBlog</h1></a>

</div>

<ul>

<li><a class="active" href="index.php">Home</a></li>

<li><a href="#news">News</a></li>

<li><a href="#contact">Contact</a></li>

<li><a href="#about">About</a></li>

</ul>

</div>

<!-- // navbar -->



<!-- Page content -->

<div class="content">

<h2 class="content-title">Recent Articles</h2>

<hr>

<!-- more content still to come here ... -->

</div>

<!-- // Page content -->



<!-- footer -->

<div class="footer">

<p>MyViewers &copy; <?php echo date('Y'); ?></p>

</div>

<!-- // footer -->



</div>

<!-- // container -->

</body>

</html>

We include some Google Fonts links between the <head></head> tags. We also provide the link of our style file public_styling.css. Our entire application wrap with the container <div> that include navbar, footer sections of the page.

To view these go to: http://localhost/complete-blog-php/index.php.

For the styling of the site the static folders will hold. Inside the static folder create 3 folders: css, images, js. In the CSS subfolder you just create file: public_styling.css.

Open public_styling.css and paste the following code:

/****************
*** DEFAULTS
*****************/
* { margin: 0px; padding: 0px; }

html { height: 100%; box-sizing: border-box; }
body {
  position: relative;
  margin: 0;
  padding-bottom: 6rem;
  min-height: 100%;
}
/* HEADINGS DEFAULT */
h1, h2, h3, h4, h5, h6 { color: #444; font-family: 'Averia Serif Libre', cursive; }
a { text-decoration: none; }
ul, ol { margin-left: 40px; }
hr { margin: 10px 0px; opacity: .25; }

/* FORM DEFAULTS */
form h2 {
  margin: 25px auto;
  text-align: center;
  font-family: 'Averia Serif Libre', cursive;
}
form input {
  width: 100%;
  display: block;
  padding: 13px 13px;
  font-size: 1em;
  margin: 5px auto 10px;
  border-radius: 3px;
  box-sizing : border-box;
  background: transparent;
  border: 1px solid #3E606F;
}
form input:focus {
  outline: none;
}
/* BUTTON DEFAULT */
.btn {
  color: white;
  background: #4E6166;
  text-align: center;
  border: none;
  border-radius: 5px;
  display: block;
  letter-spacing: .1em;
  margin: 10px 0px;
  padding: 13px 20px;
  text-decoration: none;
}
.container {
  width: 80%;
  margin: 0px auto;
}
/* NAVBAR */
.navbar {
  margin: 0 auto;
    overflow: hidden;
  background-color: #3E606F;
    border-radius: 0px 0px 6px 6px;
}
.navbar ul {
    list-style-type: none;
    float: right;
}
.navbar ul li {
    float: left;
    font-family: 'Noto Serif', serif;
}
.navbar ul li a {
    display: block;
    color: white;
    text-align: center;
    padding: 20px 28px;
    text-decoration: none;
}
.navbar ul li a:hover {
  color: #B9E6F2;
    background-color: #334F5C;
}

/* LOGO */
.navbar .logo_div {
  float: left; 
  padding-top: 5px;
  padding-left: 40px;
}
.navbar .logo_div h1 {
  color: #B9E6F2;
  font-size: 3em;
  letter-spacing: 5px;
  font-weight: 100;
  font-family: 'Tangerine', cursive;
}

/* FOOTER */
.footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  color: white;
  background-color: #73707D;
  text-align: center;
  width: 80%;
  margin: 20px auto 0px;
  padding: 20px 0px;
}

This code starts with default styling that is followed by navbar styling. We create the include folder as beginning we repeating the head sections, the footer and the navbar. We create a folders at the beginning named includes. Now we create three sections on this three folders head section.php, navbar.php and footer.php.

Go to the index.php file and include the <meta charset = “UTF – 8”> tag directly into <title> and cut it. The newly created file complete-blog-php/includes/head_section.php and paste the code in it. So, head_section.php file has following code –

<!DOCTYPE html> <html> <head> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css?family=Averia+Serif+Libre|Noto+Serif|Tangerine" rel="stylesheet"> <!-- Styling for public area --> <link rel="stylesheet" href="static/css/public_styling.css"> <meta charset="UTF-8">
 

After that back in index.php file, and replace the code as following line –

<?php require_once('includes/head_section.php') ?>

The immediately follows this include line in the <title> tag. The include line is <title> tag in the head_section.php. In the index.php file indicates the comment and past navbar.php the following code –

<div class="navbar">

<div class="logo_div">

<a href="index.php"><h1>LifeBlog</h1></a>

</div>

<ul>

<li><a class="active" href="index.php">Home</a></li>

<li><a href="#news">News</a></li>

<li><a href="#contact">Contact</a></li>

<li><a href="#about">About</a></li>

</ul>

</div>

Paste the following line –

<!-- navbar -->

<?php include('includes/navbar.php') ?>

Past in the footer.php file the following line –

<div class="footer">

<p>MyViewers &copy; <?php echo date('Y'); ?></p>

</div>

</div>

<!-- // container -->

</body>

</html>

Created config.php file as in index.php. now use variable ROOT_PATH in the included files. After all these changes index.php will look like this:

<!-- The first include should be config.php -->

<?php require_once('config.php') ?>

<?php require_once( ROOT_PATH . '/includes/head_section.php') ?>

<title>LifeBlog | Home </title>

</head>

<body>

<!-- container - wraps whole page -->

<div class="container">

<!-- navbar -->

<?php include( ROOT_PATH . '/includes/navbar.php') ?>

<!-- // navbar -->


<!-- banner -->

<?php include( ROOT_PATH . '/includes/banner.php') ?>

<!-- // banner -->


<!-- Page content -->

<div class="content">

<h2 class="content-title">Recent Articles</h2>

<hr>

<!-- more content still to come here ... -->

</div>

<!-- // Page content -->


<!-- footer -->

<?php include( ROOT_PATH . '/includes/footer.php') ?>

<!-- // footer -->

This is mainly the basic steps that set up in the public area. In this process. You can quickly learn how to create a blog in PHP and a MySQL database. Hope you enjoy the tutorial session.

database my sql php WordPress

Share

Post navigation

Previous: Top 5 WooCommerce Plugins – Best Selling 2022
Next: Design and Innovation – Google Search Engine

Free Download

Woo Product Table (Free Version)

Checkout Added to cart

Min Max Quantity & Step Control (Free)

Checkout Added to cart

UltraAddons Elementor (Free)

Checkout Added to cart

Premium Plugins

Woo Product Table Pro

  • Billed once per year until cancelled

  • Billed once per year until cancelled

  • Billed once per year until cancelled

Checkout Added to cart

Min Max Step Control Pro

  • Billed once per year until cancelled

  • Billed once per year until cancelled

  • Billed once per year until cancelled

Checkout Added to cart

Recent Posts

  • Common Mistakes in Software Development and Ways to Avoid Them
  • Top five WordPress Page Builders
  • What is a Woo Product Table?
  • The 7 Principles of Conversion-Centered Landing Page Design
  • Potential analysis of social media channels in relation to the success of customer retention
  • How To Fix Common SSL Issues in WordPress
  • 12 Tips to Create a WordPress Blog
  • Why don’t WordPress Posts not showing on mobile
  • How to Prevent a 504 Gateway Timeout in WordPress
  • How to login into a WordPress site using the phone number
  • How to Show Widgets on Specific Pages in WordPress
  • How do I Fix Mobile Menu in WordPress?
  • How to Delete WordPress Site from Host gator

Categories

  • Advanced Custom Fields
  • Advanced Search
  • Business Idea
  • Custom Fields WooCommerce
  • Custom Taxonomy
  • E-Commerce
  • Errors
  • Featured Tutorial
  • Instant Search
  • Min Mx
  • Multiple Product to Cart
  • News
  • Online Business
  • Personal
  • PHP
  • Plugin
  • Product Variation
  • Programming
  • Quick Buy
  • Theme
  • Tips and Tricks
  • Uncategorized
  • Woo Product Table pro
  • WooCommerce
  • WooCommerce Filter
  • WooCommerce Product Table
  • WooCommerce Product Table Free
  • Wordpress
Trustpilot

Subscribe to our Newsletter

Resources

  • Support
  • Coupons
  • Blog & News
  • Write For Us
  • Video Tutorials
  • Affiliate Program

Company

  • Our Service
  • Get Quote
  • Refund Policy
  • Privacy Policy
  • Support Policy
  • Terms of Service

Powered By

© 2022, CodeAstrology. All Rights Reserved.
  • Privacy Policy
  • Terms of Service
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT