I m creating a user based website in Wordpress, where each users can create an account and upload data of their records into the website. But I m having trouble thinking of how users can view a database table that presents relevant data to the user.
Its a golf website where the user can lodge in their exercises, what equipment they used and when they exercised.
I m trying to query from my database table for data specific to a currently login user. There is going to be a table named "exercise_record" and each WP user can view their own exercise record i.e.
global $wpdb;
$table_name = $wpdb ->prefix. 'exercise_record';
$current_user = wp_get_current_user(); // Getting current user logged in.
$user_id = $current_user->ID; // Get user ID to use in meta function.
$rows = $wpdb->get_results(
"SELECT *
FROM $table_name'
WHERE user = %d", $user_id
);
foreach ($rows as $row)
{
$row->, 'exercise_record'
}