I have a script that I'm playing with shown below. I'm trying to make a page so that when the user clicks on the checkbox called 'attend[]' they are subscribed to an event or if they uncheck it they are not subscribed to that event. How can I make this work?
Right now when you click on the checkbox I have a database field that keeps growing like a counter for all the people who signup. But, How can I keep track of all the members who sign up by their username?
if (isset($_POST['Submit']) && is_array($_POST['attend'])){
/////////
$deleted = 0;
foreach ($_POST['attend'] as $id)
{
if (mysql_query("UPDATE events SET attending=(attending+1) WHERE location='$id'")) {
$deleted += mysql_affected_rows();
} else {
die("SQL error:<br />" . mysql_error());
}
}
echo "You have successfully been added to: ($deleted) events.";
} else {
if (isset($_POST['Submit'])){
mysql_query("UPDATE events SET attending=(attending-1) WHERE location='$attend' AND attending > 0");
echo "You have been removed from this event";
}
}
ANY IDEAS? SUGGESTION?? GREATLY APPRECIATED