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 8962255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:05:34+00:00 2026-06-15T16:05:34+00:00

I am trying to build a simple randomised voting system for a site, currently,

  • 0

I am trying to build a simple randomised voting system for a site, currently, and I believe wrongly, I have the following setup

as the user goes to the random voting section of the site, he is presented with a votable item that firstly, is an item that was last voted on the longest time agp, Secondly, isn’t something the user voted for before and thirdly must be relevant to them based upon their list of relevant subjects. As a side note, if the user skips the vote, it can’t show them the same thing again later in the list and all the single votes must be recorded to produce statistics.

Currently, the way I am doing this is by holding a serialized array against their account in the database containing a list of vote item Id numbers that they have previously voted for.
I would like to say at this point that I don’t condone this, and inserting a serialized array into the database was silly, and I regret my actions 😉 .

Nevertheless, I couldn’t figure out another way to do this. at this point, the array is built upon by users voting which adds to the list. but the query would become massive if I was to continue and someone had up to 100 things they could vote for. At this point I am using this query to get the next item in the list:

//$finarr is the received unserialized list of values from the database

$sql = "SELECT * FROM vote_item_headers WHERE Id NOT IN (".$finarr.") ORDER BY LastVoted DESC LIMIT 1"

//execute query and display results

I should also note that at this point, I haven’t even bothered adding in the third requirement above because frankly, I didn’t even know where to begin or anything when I had to make a query that needed to encompass all of the requirements above.

A bit more information you might find relevant:
I have some other tables which are explained below.

core_users = list of users and their interests
core_interests = a list of all interests
core_language = a list of the different possible languages that an item could fall into
vote_item_headers = a list of all the votable items with a reference in the interests and lang tables to define extra properties of the votable item.
core_votes = the master list of people’s votes

I am really sorry if this is too vague for you guys, all I really want is guidance in this instance when dealing with large amounts of information that needs to be combined to get a result.

Any suggestions welcome. I am happy to restructure the entire thing just to get it right.

  • 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-15T16:05:35+00:00Added an answer on June 15, 2026 at 4:05 pm

    voted

    user_id   | Id
    ----------+------
        1     | 12
        1     | 14
        1     | 187
        2     | 23
    
    SELECT * FROM vote_item_headers 
        WHERE Id NOT IN (
            SELECT Id FROM voted WHERE user_id=1234
        ) 
        ORDER BY LastVoted DESC LIMIT 1
    

    but you also want relevant posts

    relevant_posts

    user_id   | Id
    ----------+------
        1     | 342
        1     | 253
        1     | 32
        2     | 53
    
    SELECT vote_item_headers.* FROM vote_item_headers 
        # cut down the amount returned with relevant_posts table
        INNER JOIN relevant_posts ON (
            vote_item_headers.Id=relevant_posts.Id
            AND user_id=1234
        ) 
        WHERE vote_item_headers.Id NOT IN (
            SELECT Id FROM voted WHERE user_id=1234
        ) 
        ORDER BY LastVoted DESC LIMIT 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple User Template system so that my users can
I'm trying to build a simple user authorization system where a .txt file stores
I'm trying to build a simple user setting feature for my school project. I've
I'm trying to build a simple parser, and since InputStream doesn't have some peek-like
Im trying to build a simple faye realtime based notification system so I can
I'm trying to build a simple component extending spark.components.Group to have a background color,
I'm trying to build a simple site but I'm just blocking on this weird
I'm trying to build simple facebook application with 4.2.1 C# SDK. But I have
I am trying to build a simple desktop application where the user enters the
Im trying to build a simple application in python, where I have tags that

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.