Passing Current User ID into SQL statement
Question
I have the following code:
$userID = get_current_user_id();
echo $userID;
$sql ="
SELECT wp_users.`user_email`,
wp_wp_pro_quiz_statistic.`correct_count`,
wp_wp_pro_quiz_statistic.`incorrect_count`,
wp_wp_pro_quiz_category.`category_name`
FROM wp_users
INNER JOIN wp_wp_pro_quiz_statistic_ref
ON wp_users.`ID` = wp_wp_pro_quiz_statistic_ref.`user_id`
INNER JOIN wp_wp_pro_quiz_statistic
ON wp_wp_pro_quiz_statistic_ref.`statistic_ref_id` = wp_wp_pro_quiz_statistic.`statistic_ref_id`
INNER JOIN wp_wp_pro_quiz_question
ON wp_wp_pro_quiz_statistic.`question_id` = wp_wp_pro_quiz_question.`id`
INNER JOIN wp_wp_pro_quiz_category
ON wp_wp_pro_quiz_question.`category_id` = wp_wp_pro_quiz_category.`category_id`
WHERE wp_users.`ID` = $[userID]";
How can I correctly pass the current user ID into the WHERE clause?
0
mysql, php
3 years
2020-06-08T10:11:36-05:00
2020-06-08T10:11:36-05:00 0 Answers
96 views
0
Leave an answer