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

  • Home
  • SEARCH
  • 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 6686861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:13:15+00:00 2026-05-26T05:13:15+00:00

I am having a problem locating comments for a given user with the following

  • 0

I am having a problem locating comments for a given user with the following table structure:

usertable (id, userid, name)
comments (id, commentname, date)

Note: usertable.id is not the same as comments.id, and they are both autoincrement

How should I go about updating these tables to fix this problem?


Update

Is this code good for all users get their own votes when someone voted as thilo savage told me ?

$sth = thumbsup::db()->prepare(
     'INSERT INTO'
    .thumbsup::config('database_table_prefix')
    .'votes_users(vid, userid) VALUES (?,?)');

$sth->execute(array($this->vid, $userid));
  • 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-05-26T05:13:16+00:00Added an answer on May 26, 2026 at 5:13 am

    EDIT: Rewritten to use many-to-many relationship because current tables can’t be altered.

    Create a new table called comments_users with these fields:
    cuid (primary key and auto increment) | cid | uid

    Then get all of a user’s comments with this code:

        $user_id = '1234';
    
    // get all the user's comment ids from comments_users table
    $find = mysql_query("SELECT `cid` FROM `comments_users` WHERE `uid` = '".$user_id."'");
    
    // generate a query that grabs all those comments
    $load = "SELECT * FROM `comments` WHERE ";
    while ($row  = mysql_fetch_array($find) {
        $load .= "`id` = '".$row['cid']."' OR ";
    }
    
    // shop off the last OR
    $load = substr($load,0,-4);
    
    // put all the user's comments into comments array
    $q = mysql_query($load);
    while ($comment = mysql_fetch_array($q)) {
        $comments[] = $comment
    }
    
    print_r($comments);
    

    As far as inserting goes, you’ll insert comments into the comments table like you normally would, but then you’d ALSO insert a row into comments_users table filling in the appropriate cid and uid for that comment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
m having problem in passing parameter to controller action, i have done the following
Hi i am having problem inserting data into multiple table from one view. First
Having problem in IE8 with vertical align for images not working when a table
I´m having problem using validation on DropDownListFor ... My Model : public class User
Am having problem in using simple date format for this: having date as 12/13/2011
I'm having a problem locating anything on converting RAE to XYZ. If I am
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
We're having problem with a huge number of legacy stored procedures at work. Do
We are having problem with the server migration. We have one application that are

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.