How to insert data in wordpress database table with functions.php?

function adc_insert_dummy_students() {
global $wpdb;
$table_name = $wpdb->prefix . “students”;

// Insert ONE simple dummy row (no echoes)
$wpdb->insert(
    $table_name,
    array(
        'firstname' => "Jagwinder",
        'lastname'  => "Kaur",
        'class'     => "MSc",
        // other fields may be empty; table allows NULL/empty per schema
    ),
    array('%s','%s','%s')
);

}

Share on Facebook Share on Twitter