I know that there are quite a few different topics out there but I don’t believe they are exactly what I’m looking for.
I need to make a database using MySQL for a club I’m in. I want to create a webpage that the Secretary can log into and take attendance for the meeting. First off I need to know what exactly I would need for creating the table.
I was thinking something like
CREATE TABLE 'Members'('memberName' VARCHAR(40) NOT NULL,
'11/1/11' INT NOT NULL DEFAULT 0,
'totalAttendance' INT NOT NULL DEFAULT 0,
PRIMARY KEY('memberName'), UNIQUE INDEX 'memberName'_UNIQUE('memberName' ASC));
and just keep adding columns for the date using ALTER TABLE 'Members' ADD '11/8/11' INT NOT NULL DEFAULT 0;
I was going to use PHP to create the column and change the default 0 to a 1 if they attended (not exactly sure how I was going to do that but I was thinking some check boxes and if they are checked edit that column for that name?) So something like mysql_query("UPDATE 'Member' SET 'meetingDate'='1' WHERE memberName='nameOfMember'") I believe.
or die(mysql_error());
What I really need is a way to count across each column to count the total number of times each member has attended and then placing that into the totalAttendance column.
Can someone help me out with that? I’m thinking it is a really easy statement I’m just not asking Google the correct question. Thank you for any help you can give.
I’d suggest you set up something like this:
So you’d have a row for each member for each meeting whether they attended or not. My guess is you’re not going to have millions and millions of rows with this system, so don’t worry about performance.
You can get the total attendance for a member with something like:
You can get the total attendance for a meeting with something like:
You can get all of the members that missed a specific meeting with something like: