How to Insert Data into Table using WPDB

WPDB is a WordPress class containing a set of functions to interact with Database. In this article, you will learn the use of WPDB‘s “insertfunction that is used for inserting rows into tables.

Insert your values in the table by using the following method:

Here, ‘pt_my_table_name’ is the name of table in which you want to insert the record. ‘name’, ‘email’ and ‘phone’ are the names of database columns. While ‘PressTigers’, ‘’ and ‘123456789’ are the values for these columns respectively.

You can change the values of database table name and columns as per your requirement. Values can also be inserted using a PHP variable for dynamic values. You can use your variables to insert values in database in the following way as well:

Here $pt_name, $pt_email and $pt_phone are the variables containing values for the columns to be inserted.

User Comments

1 thought on “How to Insert Data into Table using WPDB

    Abdelilah Hamdani says:

    THanks alot!!

Leave a Reply

Your email address will not be published. Required fields are marked *

    Get in Touch