I have a form that submits lots of small fields that I need to loop through and perform actions on.
The form looks like this:
Also see the function explode()
http://www.php.net/manual/en/function.explode.php
You can loop over $_POST and read the values: http://www.php.net/manual/en/reserved.variables.post.php
foreach($_POST as $key =>$value){
// do something using key and value
}
Look into the use of explode() and POST variables.
Try something along the lines of:
// Loop over each item in the form.
foreach($_POST as $name => $value) {
// Split the name into an array on each underscore.
$splitString = explode("_", $name);
// If the data begins with "minnight", use it.
if ($splitString[0] == "minnight") {
// Set the other desired values into variables.
$secondValue = $splitString[1];
$thirdValue= $splitString[2];
// Database query goes here.
}
}