xionhack Posted November 26, 2009 Share Posted November 26, 2009 Hello. I have a form, where you can vote for different songs. What I want is for you to only be allowed to vote 3 times a week, the voting system being reset every monday at 12:01 am. How can I do that? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/ Share on other sites More sharing options...
jamesxg1 Posted November 26, 2009 Share Posted November 26, 2009 Do you mean 3 votes in total or 3 votes per person ? James. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965813 Share on other sites More sharing options...
xionhack Posted November 26, 2009 Author Share Posted November 26, 2009 3 votes per person ( the person is signed in to vote.) Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965816 Share on other sites More sharing options...
jamesxg1 Posted November 26, 2009 Share Posted November 26, 2009 Ok, make a table with something like this. Username (VARCHAR) | Votes (INT). and when they vote run a insert setting a username and vote to 1 then on there next vote use a update to change that 1 to 2 with a where username = session ect. James. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965819 Share on other sites More sharing options...
xionhack Posted November 26, 2009 Author Share Posted November 26, 2009 How will it reset every week? and also, they can vote for more than 1 song at the same time. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965822 Share on other sites More sharing options...
jamesxg1 Posted November 26, 2009 Share Posted November 26, 2009 The voting site with the values will be kept somewhere else and the vote count (the amount of times they have voted) will be kept in the VOTE table and a cron job maybe. James. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965824 Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2009 Share Posted November 26, 2009 The simplest system is to record (in a database table) each vote, with the member id, datetime of the vote, and what they voted for. Then it is a simple matter to query for the count of votes in the time period you are interested in and if that count is less than the limit, allow a new vote. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965827 Share on other sites More sharing options...
xionhack Posted November 26, 2009 Author Share Posted November 26, 2009 Yes! that is actually what I had in mind. But I dont know which query to put that tells me how many votes have done only this week, or how many votes have left. Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965831 Share on other sites More sharing options...
jamesxg1 Posted November 26, 2009 Share Posted November 26, 2009 $query = "SELECT * FROM `votes` WHERE username = '$username'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)): if($row['votes'] > 3) { // no } else { // yes } endwhile; Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965833 Share on other sites More sharing options...
xionhack Posted November 26, 2009 Author Share Posted November 26, 2009 Yes jamesxg1, but its not only 3 votes at the same time, but 3 votes during the whole week! they can do 1 for 3 days, 3 the same day, 2 one day and 1 another, anyway they want! Quote Link to comment https://forums.phpfreaks.com/topic/182985-only-allow-3-votes-a-week/#findComment-965836 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.