logo

Extra Block Types (EBT) - New Layout Builder experienceâť—

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

âť—Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Blog

PHP Lessons - Lesson 3.2 - Working with MySQL DB. Inserting data INSERT INTO. Selecting data SELECT

16/04/2025, by Ivan

In the previous lesson, we created a table for our website. In this lesson, we will improve the table and start working with the database: adding and retrieving data from it. I don’t think anything too difficult is coming up, so let’s begin.

First, I suggest we improve our messages table. Right now it has fields for the data, but it needs an extra column for numbering records. If you look at the Drupal database, the node table has a nid field for this purpose. We’ll do something similar with our messages table.

PHP Lessons - Lesson 3.3 - Working with MySQL DB. Updating data UPDATE.

16/04/2025, by Ivan

We have already learned MySQL operators like SELECT and INSERT INTO. Now it's time to learn how to update existing data in the database using the SQL UPDATE operator. But first, let's modify our index.php file and add a new route. Find this code:

if ($_GET['admin'] == 1) { 
  print $obj->display_admin(); 
} else {
  print $obj->display_public(); 
}

And replace it with the following code:

PHP Lessons - Lesson 3.4 - Working with MySQL DB. DELETE Deletion Queries.

16/04/2025, by Ivan

In the previous lesson, we learned how to add new methods to our management class simpleCMS. Now let’s add one more method to delete a record: delete().

We’ll add the method as usual:

public function delete($mid) {
    
}

As you can see, we pass a parameter $mid – the ID of our record. If you recall the previous lesson, we used a different approach to pass the parameter via a GET request. This time we’ll try passing the parameter another way.

PHP Lessons - Lesson 3.5 - Working with MySQL DB. JOIN operator. Uploading files to the server.

16/04/2025, by Ivan

Before I started writing this lesson, I thought for a long time about the best way to present queries using the JOIN operator. The point is that the JOIN operator is used to retrieve data from multiple tables at once. And since we need another table, let's create one. I suggest creating a table for files, which we will upload through a form in this lesson. This way, the lesson will combine two directions: working with databases and working with forms.

PHP Lessons - Lesson 3.6 - Working with MySQL DB. Types of JOIN operator.

16/04/2025, by Ivan

In MySQL, JOIN queries can be written in several different ways. We'll try to cover all of them. Here's a list of JOIN query types:

  1. INNER JOIN
  2. LEFT JOIN
  3. LEFT JOIN without matches in the right table
  4. RIGHT JOIN
  5. RIGHT JOIN without matches in the left table
  6. FULL OUTER JOIN
  7. FULL OUTER JOIN where the left or right table is empty

Here’s an illustration of these types of JOINs:

SQL

PHP Lessons - Lesson 4 - Working with Images, GD2 Library

16/04/2025, by Ivan

In the previous lessons, we learned how to write database queries, so now we'll focus less on writing queries and more on practicing them. We'll also combine writing queries with learning other PHP features, starting with image processing. In one of the previous lessons, we already uploaded files and even created a Files table for uploaded files. Now, let’s upload images to the same table. But first, we need to add a photo upload field to the content creation form.

1.2. What will be in our CMS

16/04/2025, by Ivan

After reviewing existing commerce sites, we need to define the functionality of our future CMS. Obviously, we need to allow users to find and view products in various categories. Users should be able to order these products by adding them to the cart and going through the checkout process, filling in order details to calculate shipping, payment, and taxes. We will also build an admin panel for managing orders and products. Below is a detailed list of all features:

Products

We need to implement the following functionality for products:

1.3. Building our PHP framework

16/04/2025, by Ivan

There are many different ways to construct a framework. Some people prefer very complex frameworks, while others prefer very simple ones. In our articles, we’re going to quickly build a framework that is easy to use and easy to understand.

Our articles will help you develop your own framework, different from the one we’re building for an online store. You’ll be able to easily add other parts to the framework to create something bigger. The main goal of this article series is to teach you how to build your own framework for any CMS.