1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rating Script

Discussion in 'MySQL' started by warpser, Mar 30, 2010.

  1. #1
    I'm trying to develop a star rating script and pretty much have everything done.

    My question is what's the best way to keep track of the Members that have voted each item? Currently I have it with 1 table that lists each rating based on a unique name given to them.
    For example: I have an image i want people to rate so once they click on a rating I put it in a row with a unique name for it along with total accumulated votes and total vote points. So each row will be a new item with it's own count of votes and such.

    To prevent duplicate voting Member Names are added in a column named "banned" on the same row of the unique item, last field. I add a new Member Name to the field each time someone votes separated by a comma. To check if they voted I simply explode it into an array and check before it loads.

    So is this really the best way to handle this? I have not been able to think of how else to do it effectively.
    Any help or suggestions are greatly appreciated.
     
    warpser, Mar 30, 2010 IP
  2. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #2
    its better to create another table that stores the image id, and username, then check that table before updating the vote count... Or you can also remove the vote count from the image table and just count the number of rows in the new table for the image id.
     
    killaklown, Mar 30, 2010 IP
    warpser likes this.
  3. warpser

    warpser Active Member

    Messages:
    294
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks for the reply killaklown

    That makes sense, currently I have to look through the entire array to find out if they have voted... where you're way I would have a lot more records in another table i would call "Banned" but I could easily found out if the record exists by using WHERE.

    So this would mean img id would exist multiple times each time a member votes? (Each IMGID = Different Picture)

    Columns: uniqueIMGID | MEMBER
    --------------------------------------
    ROW1: [ IMGID#1 ] - [ JOHN ]
    ROW2: [ IMGID#2 ] - [ MARK ]
    ROW3: [ IMGID#1 ] - [ MARK ]
    ROW4: [ IMGID#4 ] - [ ESSICA ]
    ROW5: [ IMGID#1 ] - [ JESSICA ]

    Would that have an impact on the time it takes to return the result if there are that many records?
     
    warpser, Mar 30, 2010 IP