SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Poll photos

Hybrid View

  1. #1
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    408
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Poll photos

    Hi guys, hope in your help.
    In this table mysql register the poll photos.
    Code:
    DateVote
    IP
    idphoto
    Rating
    id
    I need prevent a user from voting more than once for the same photo ... and tried this query working:
    Code:
    SELECT
    	COUNT(*)
    FROM
    	tbl_UserRatings
    WHERE
    	IP = '127.0.0.1'
    AND idphoto = 1
    But I would like to put a check on the date ... the poll is open from 20 sept to 27 sept, can you help me?
    Thank you

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,338
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    it's really simple, declare a UNIQUE index on { DateVote,IP,idphoto }

    then you won't even need to run your COUNT query at all
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    408
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Very nice!
    thanks a lot!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •