Migrate table from CSV

[ad_1]

I’m trying to implement a client dashboard. I have around 100 users and all of their data is stored in an sql table I’ve exported as a csv file. Each user has a unique code which corresponds to rows in the table.

My question: How can I import the csv into my WordPress database? I want to access and display the rows returned for a specific user in the table using the “wpdb” object with the “wpdb->get_results()” method.

Any help is appreciated!

[ad_2]
1 Comment
  1. Yes, you’re on the right track. You can import your data into custom tables, and include a column as a way to identify the owner, that’s then linked to the wp_users table eg user_id

    <?php
    $uid = get_current_user_id();
    if ($uid > 0) {
    $results = $wpdb->get_results($wpdb->prepare”SELECT * FROM your_custom_table ct WHERE ct.ownerID = %d”, $uid);
    }
    else { echo ‘not logged in’; }
    ?>

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer