activity
and
activity_options
Say activity contains: Exercise with id of 1
and the activity_options for that Exercise are stored in activity_options - ie running, jumping, skipping. These activity_options all have the same activity_id of 1 so I can link them to each other.
Now I am outputting a form so users can Update any names of either the Activity or the options, but because a random number of options can be associated with 1 activity I made a loop that outputs a form. After this is where I am getting stuck. I have output the form ok but when I post the option_id and option name I am struggling to get my head around how to process the results as assigning the id to a variable doesn't work as there is a random number of option id's!
Code: Select all
echo "Activty id = " . ($_POST['selectactivity']);
echo '<form action="edit_activity" method="post" name="Edit Activity">';
echo 'Activity:' . "<br />";
echo '<input name="event" value="' . $row['event'] . '" /><br /><br />';
echo '<input name="id" type="hidden" value="' . $row['id'] .'" />';
echo '<br />Options:<br />';
while ($row = mysqli_fetch_array($result2)) {
echo '<input name="'. $row['id'] .'" value="' . $row['options'] . '" /><br /><br />';
}
echo '<br /><p><input type="submit" name="submit" value="Save" /></p></form>';
This code updates the activity fine but how do I then do the events!??
Code: Select all
$activityid = $_POST['id'];
$event = $_POST['event'];
$sql = sprintf("UPDATE activity SET event='%s' WHERE id='%s LIMIT 1'", $event, $activityid);
if (!mysqli_query($dbc, $sql))
{
die('<br /><br />Error!');
}