Support » Plugin: EZ SQL Reports Shortcode Widget and DB Backup » SQL query for current user Report

  • Resolved SheriW7


    Hi Eli,

    Thank you for the plugin. I do not know how to write SQL queries, and would like to use your plugin for producing some reports that are for the Current User’s activities on my site. I’m trying to produce a report that will show scores for quizzes that a user took.

    Below is what I have so far which produced the saved report. It displays the report on my page but shows the report as “empty.” Would you be able to write me the proper query to use? answered, correct, and quiz are the columns in a table called ssquiz_users. I’d like to show this data for the Logged in user (just for the quizzes that they took). I appreciate any help you can provide.

    SELECT answered, correct, quiz FROM ssquiz_users, wp_users WHERE user_name = ‘<?php $current_user->ID ?>’

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Eli


    Well you don’t need the wp_users table if ssquiz_users has a user_id field, and you should be using that user_id filed in you where not user_name.

    So, maybe this will work:
    SELECT answered, correct, quiz FROM ssquiz_users WHERE user_id = <?php $current_user->ID ?>

    I tried that and received this error message: ERROR: Unknown column ‘user_id’ in ‘where clause’ SQL:SELECT answered, correct, quiz FROM ssquiz_users WHERE user_id = 1

    Any other thoughts on how to pull this report? Thanks Eli, Sheri

    Plugin Author Eli


    ok, so there is no user_id in the ssquiz_users table, but there must be a field in that table that relates to the user that took the quiz. Find out what the filed is called and use that.

    I got this below to work. Thanks for your guidance. Your plugin is going to help me a great deal to display reports for each user – awesome!

    SELECT answered, correct, quiz, date_stamp FROM ssquiz_users WHERE user_email = ‘<?php $current_user->user_email ?>’

    Plugin Author Eli


    Great! I’m glad you figured it out.

    Don’t forget to donate if you can so that I can keep making improvements and adding new features.

    Aloha, Eli

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘SQL query for current user Report’ is closed to new replies.