how to insert data in table and fetch in wordpress

To insert data into a table in WordPress, you can follow these steps:

Step 1: Use the $wpdb Object to Insert Data

global $wpdb;
$table_name = $wpdb->prefix . 'your_table_name';
$wpdb->insert(
    $table_name,
    array(
        'column1' => 'value1',
        'column2' => 'value2'
    )
);

Step 2: Fetch Data from the Table

$results = $wpdb->get_results( "SELECT * FROM $table_name" );
foreach ( $results as $result ) {
    echo $result->column1;
    echo $result->column2;
}

Hope this helps!