Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8116011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:40:29+00:00 2026-06-06T03:40:29+00:00

I am making a recent activity tab to profiles on my site and I

  • 0

I am making a “recent activity” tab to profiles on my site and I also am going to have a log for moderators to see everything that happens on the site. This would require making an activity log of some sort.

I just don’t know what would be better. I have 2 options:

  1. Make a table called “activity” and then every time someone does something, add a record to it with the type of action, user id, timestamp, etc.
    • Problem: table could get very long.
  2. Join all 3 tables (questions, answers, answer_comments) and then somehow show all these on the page in the order in which the action was taken.
    • Problem: this would be extremely hard because I have no clue how I could make it say “John commented on an answer on Question Title Here” by just joining 3 tables.

Does anyone know of a better way of making an activity log in this situation? I am using PHP and MySQL. If this is either too inefficient or hard I will probably just forget the Recent Activity tab on profiles but I still need an activity log for moderators.

Here’s some SQL that I started making for option 2, but this would not work because there is no way of detecting whether the action is a comment, question, or answer when I echo the info in a while loop:

SELECT q.*, a.*, ac.* 
    FROM questions q JOIN answers a ON a.questionid = q.qid
        JOIN answer_comments ac ON c.answerid = a.ans_id
WHERE q.user = $userid 
AND a.userid = $userid 
AND ac.userid = $userid
    ORDER BY q.created DESC, a.created DESC, ac.created DESC

Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:40:31+00:00Added an answer on June 6, 2026 at 3:40 am

    Why do you have q.user and q.userid?

    For option 2 (the better option IMO – as long as you’ve indexed properly), I think a UNION is more what you’re looking for. Something like this:

    SELECT 'question' AS action, id, created 
        FROM questions WHERE userid = {$userid}
        UNION
    SELECT 'answer' AS action, id, created
        FROM answers WHERE userid = {$userid}
        UNION
    SELECT 'comment' AS action, id, created
        FROM answer_comments WHERE userid = {$userid}
    ORDER BY created DESC LIMIT 20
    

    The 'question' / 'answer' / 'comment' tells you which action was taken. Possible issues you may run into: being a UNION, each SELECT statement must have the same number of columns, so if one is short, you can just add a NULL e.g.:

    SELECT 'comment', id, created, NULL FROM ac
    

    Also, if one of the created columns has a different name you can just alias

    SELECT 'comment', id, comment_date AS created FROM ac
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a UITableView with a UISegmented control ala the Recent Calls tab
I'm making a website for a organization that also has a facebook group, and
Recent events on the blogosphere have indicated that a possible performance problem with Scala
Making a new site but something is happening to it in IE8. The social
Making a word document of our network set-up. We have about 7 servers and
Making a new site but something is happening to it in IE. I've purchased
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
I am working on making a paged app that will load a separate HTML
I'm making an Android app that tracks a user and displays their location in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.