WordPress.org

Ready to get started?Download WordPress

Forums

ELI's SQL Admin Reports Shortcode and DB Backup
[resolved] SQL query for current user Report (6 posts)

  1. SheriW7
    Member
    Posted 1 year ago #

    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 ?>'

    http://wordpress.org/extend/plugins/elisqlreports/

  2. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    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 ?>

  3. SheriW7
    Member
    Posted 1 year ago #

    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

  4. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. SheriW7
    Member
    Posted 1 year ago #

    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 ?>'

  6. Eli
    Member
    Plugin Author

    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic