I am a newbie at PHP and at a loss here. I need to iterate over rows
in a database, and display them as editable fields in HTML. I can do
this okay. However, I then need to be able to take a 'snapshot' of
all changes made and update a DB table with a single "Submit" button.
Can this be done? Below is a simple example of what I'm trying to do.
I know it is bad form to try and combine two variables into one, but
do not know what else to do. I cannot get arrays to work with this.
The below code will error out with "$color undefined" Any way to
'combine' two variables as can be done in Korn/Bash?
Sorry if this sounds confusing, let me know if any more information is
needed. Thanks for the help!
<?php
#------------------------------------
# Display Form
#------------------------------------
echo "<html><body>";
echo "<form method=\"post\" value=\"$PHP_SELF\">";
for ($i = 0; $i < 3; $i++) {
echo "<input type=\"text\" name=\"color${i}\">";
}
echo "<input type=\"submit\" name=\"btn\" value=\"Submit\">";
echo "</form></body></html>";
#------------------------------------
# Process Form
#------------------------------------
if (isset($btn)) {
echo "You chose:\n";
echo "${color}{$i}";
}