foreach ($row as $key => $value)
{
echo $key . ': <input type="text" name="data[' . $key .']" value="' . $value . '"><br>';
}
I am trying to modify the loop above so the form doesn't just show input text fields, but textareas, and checkboxes - i.e the correct fields according to those in the form.
the process here if my understanding serves me correct is:
if field type is a input text then....
foreach ($row as $key => $value)
{
echo $key . ': <input type="text" name="data[' . $key .']" value="' . $value . '"><br>';
}
or if field type is checkbox then.....
foreach ($row as $key => $value)
{
echo $key . ': <input type="checkbox" name="data[' . $key .']" value="' . $value . '"><br>';
}
or if field type is a textarea then.......
foreach ($row as $key => $value)
{
echo $key . ': <input type="textarea" name="data[' . $key .']" value="' . $value . '"><br>';
}
Is it possible to create an array in a foreach loop and in this case how?