[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]
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’; }
?>