fastpager Posted November 17, 2009 Share Posted November 17, 2009 I have a list of attendees for a selected event. At the end of each row are the radio buttons for (Present) and (Absent). It updates the first attendee in the list but not the rest. It seems that foreach ($Attendee as $checked){ should loop though the complete list of attendees. I`m doing something wrong, I need some help. Thank you. <?php // process the action inputs $sAction = $_POST['Action']; $EventID = $_POST['EID']; // from ListEvents button=Attendees $per_ID = $_POST['PerID']; $EvtName = $_POST['EName']; $EvtDesc = $_POST['EDesc']; $EvtDate = $_POST['EDate']; // delete attendees from event if ($sAction=='Drop'){ $dpeEventID=$_POST['DelPerEventID']; $dpePerID=$_POST['DelPerID']; $dpeSQL = "DELETE FROM event_attend WHERE event_id=$dpeEventID AND person_id=$dpePerID LIMIT 1"; RunQuery($dpeSQL); $ShowAttendees = 1; } // count attendees for event $checked = $_POST['Attendee']; $Attendee = array('Present','Absent'); if (isset($_POST['Attendee'])){ $attSQL = "UPDATE event_attend SET event_count='$checked' WHERE event_id='$EventID' AND person_id='$per_ID'"; } foreach ($Attendee as $checked){ $rsAttend=mysql_query($attSQL); } // Construct the form ?> <tr><td colspan="6" align="right"><input type="submit" align="right" style="font-size: 12px;" name="Attendee" value="Attendance"></td> <form method="POST" action="EditEventAttendees.php" name="DeletePersonFromEvent"> <input type="hidden" name="DelPerID" value="<?php echo $per_ID; ?>"> <input type="hidden" name="DelPerEventID" value="<?php echo $EventID; ?>"> <input type="hidden" name="EID" value="<?php echo $EventID; ?>"> <input type="hidden" name="EName" value="<?php echo $EvtName ?>"> <input type="hidden" name="EDesc" value="<?php echo $EvtDesc ?>"> <input type="hidden" name="EDate" value="<?php echo $EvtDate ?>"> <input type="hidden" name="PerID" value="<?php echo $per_ID; ?>"> <input type="radio" name="Attendee" value="Present" checked="checked">Present <input type="radio" name="Attendee" value="Absent" >Absent  <input type="submit" style="font-size: 9px;" name="Action" value="<?php echo gettext("Drop"); ?>"class="icbutton" onClick="return confirm('Are you sure you want to DELETE <?php echo $per_FirstName." " .$per_LastName; ?> from <?php echo $EvtName; ?> ?')"> </form> /code] Quote Link to comment https://forums.phpfreaks.com/topic/181923-attendance-form-with-radio-buttons/ Share on other sites More sharing options...
mikesta707 Posted November 17, 2009 Share Posted November 17, 2009 if you want the check boxes to be treated as an array, you need to signify to HTML that it is an array. so instead of the name attribute being name="Attendee" you need to set the name attribute to be name="Attendee[]". you access it normally (IE $_POST['Attendee'] but its an array now, instead of a single value Quote Link to comment https://forums.phpfreaks.com/topic/181923-attendance-form-with-radio-buttons/#findComment-959555 Share on other sites More sharing options...
fastpager Posted November 17, 2009 Author Share Posted November 17, 2009 Thanks for your help. When I added Attendee[] it updated my table column with the word "array" and only for the first attendee in the event list. Quote Link to comment https://forums.phpfreaks.com/topic/181923-attendance-form-with-radio-buttons/#findComment-959559 Share on other sites More sharing options...
fastpager Posted November 18, 2009 Author Share Posted November 18, 2009 Ok I changed the code brackets, and moved the foreach function, and now I`m not getting the word Array in my table column. But it still only updates the first person in my attendee list. I`m still doing something wrong. Need help please. Thank you. $checked = $_POST['Attendee']; $Attendee = array('Present','Absent'); if (isset($_POST['Attendee'])){ } foreach ($Attendee as $checked){ $attSQL = "UPDATE event_attend SET event_count='$checked' WHERE event_id='$EventID' AND person_id='$per_ID'"; } $rsAttend=mysql_query($attSQL); Quote Link to comment https://forums.phpfreaks.com/topic/181923-attendance-form-with-radio-buttons/#findComment-959670 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.