Jakebert Posted June 14, 2012 Share Posted June 14, 2012 Hi everyone, I'm trying to design a mock parliament: there is a bill up for vote, everyone may vote once (either AYE or NAY), but they can switch their vote. I tried it with a table VOTES with columns for BILLID (the id of the bill up for vote), USERID (the user voting) and VOTE (what they voted). The actual number of votes for each bill is stored in table BILLS. In the PHP processing the form, i have to check everything twice, i.e. did they click yes or no? if they clicked yes have they clicked yes before? have they voted no before? if they voted yes before display an error, if they voted no before remove 1 from nay and add one to ay, and then update table VOTES. And then all over again if they voted no. it looks like spaghetti. Can anyone think of an easier/more compact way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/264201-help-with-databaseform-design/ Share on other sites More sharing options...
requinix Posted June 14, 2012 Share Posted June 14, 2012 You don't have to store the number of votes (yay, nay, or total) anywhere. If you want to know then you can query your VOTES table. Quote Link to comment https://forums.phpfreaks.com/topic/264201-help-with-databaseform-design/#findComment-1353989 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.