Jump to content


Photo

Meeting Attendance in PHP/MySql


  • Please log in to reply
3 replies to this topic

#1 danwilk

danwilk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 04 March 2006 - 04:50 PM

I have created a complete package for my church to use for members and meeting minutes, etc.. but I am having trouble designing a way to submit attendance at our monthly conference meeting. I have designed a member database in MySQL where the unique key is auto generated number and I want to design something like a PHP page that lists the members and I can select them with a check box or something and it update the Attendance table. I'm not sure how to handle that part of the design. I think I might be able to write some inquiries to join the member table and the attendance tables once I get over this hurdle.

Any help is appreciated.

Thanks,
Daniel

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 05 March 2006 - 12:16 PM

Three tables

Member
---------
memberID | name | etc


Meeting
----------
meetingID | meeting_name | meeting_date


Attendance
---------------
attID
meetingID
memberID

So for each person at each meeting there is a record in the attendance table.

Have form (generate from member table) like this where checkbox value is the memberID of the member

<FORM method='POST'>
<INPUT TYPE='TEXT'  name='attend[]' value='1'> Adam
<INPUT TYPE='TEXT'  name='attend[]' value='2'> Ben
<INPUT TYPE='TEXT'  name='attend[]' value='3'> Cath
<INPUT TYPE='SUBMIT'  name='submit' value='Submit'>
</FORM>

Then to process

if (isset($_POST['submit'])) {
    foreach($_POST['attend'] as memberID) {
            // add record to attendance table
    }
}

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 danwilk

danwilk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 05 March 2006 - 02:47 PM

Barand,
I got the form to work with the checkboxes and MbrId's but for some reason I think I don't have the form processing logic correct, can you take a look? Attid is auto incremented and instead of meeting id I am using the meeting date since I am tracking only one type of meeting.

<?
$link = mysql_connect("localhost","root","pass");
 
mysql_select_db("dbname",$link);
 
$query=("insert into ConfAttendance(mbrid,confdate) or die(mysql_error())");
 
if (isset($_POST['submit'])){
for each($_POST['attend'] as Mbrid),($_POST['meetdate'] as confdate) {
mysql_query($query);
}
}
?>





[!--quoteo(post=351811:date=Mar 5 2006, 07:16 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 5 2006, 07:16 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Three tables

Member
---------
memberID | name | etc
Meeting
----------
meetingID | meeting_name | meeting_date
Attendance
---------------
attID
meetingID
memberID

So for each person at each meeting there is a record in the attendance table.

Have form (generate from member table) like this where checkbox value is the memberID of the member

<FORM method='POST'>
<INPUT TYPE='TEXT'  name='attend[]' value='1'> Adam
<INPUT TYPE='TEXT'  name='attend[]' value='2'> Ben
<INPUT TYPE='TEXT'  name='attend[]' value='3'> Cath
<INPUT TYPE='SUBMIT'  name='submit' value='Submit'>
</FORM>

Then to process

if (isset($_POST['submit'])) {
    foreach($_POST['attend'] as memberID) {
            // add record to attendance table
    }
}
[/quote]


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 05 March 2006 - 09:16 PM

<?
$link = mysql_connect("localhost","root","pass");

mysql_select_db("dbname",$link);


if (isset($_POST['submit'])){
    $confdate = $_POST['meetdate'];
    for each($_POST['attend'] as $mbrid)) {
        $query=("insert into ConfAttendance(memberID, confdate) VALUES($mbrid,'$confdate') ");
        mysql_query($query) or die(mysql_error());
    }
}
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users