Over two years ago I created some test php code to see if I could figure out how to have (a series of input text boxes in a table which is on a form) that the user could selectively update then once they were done they would click the submit button and the same php page would process them in a loop to do some updates to the file. An extract of the test code I used to see if I could get it to work is below (I stripped out the style command to make it easier to read). Because I didn't have the need at the time I didn't fully complete the code.
Now I have the need to get it working but I just realized I need to bring in the $fldMM_Key from the table via the same table loop so I know what record to update on the file. However there is no need for the user to update this data. I am assuming I have to put the $fldMM_Key in a "input textbox" as shown in the example immediately below so I can use the command $fldMM_Key = $_POST['fooMasterKey'][$RowCnt]; to capture the key. I would have to protect the text box of course but I am pretty sure I can figure out how to do that. Am I correct in thinking I can only bring in table column data from input fields or is there a way to bring in a column of table data in a loop without having to put it in a textbox? If so are there some examples kicking around? If not how might I create a google search to find them? "PHP capture table column data without an input keyword" maybe? Or maybe the trick I use "PHP = $_POST[' '][$ ]; loop" where I remove anything specific to my app would work to pull up examples and they may show what I am looking for.
Thanks,
John
Notice I have used the prefix "foo" which came from the example I learned this from. I still use ti to indicate to myself the data is from table input.
Code: Select all
echo("<td><input type='textbox' name='fooMasterKey[]' value='$fldMM_Key' size='7''></td>\n");
$fldMM_Key = $_POST['fooMasterKey'][$RowCnt];
test PHP code that is in a loop and use to create the the table of input text boxes.
Code: Select all
echo("<td>$fldMM_Key</td>\n");
echo("<td>$fldMM_FirstName</td>\n");
echo("<td>$fldMM_MiddleName</td>\n");
echo("<td>$fldMM_LastName</td>\n");
$SoundLevel1of3 = $RowCnt;
echo("<td><input type='textbox' name='foo1of3[]' value='$SoundLevel1of3' size='7' onchange='funcEditValue(this.value)'></td>\n");
$SoundLevel2of3 = $RowCnt + 1;
echo("<td><input type='textbox' name='foo2of3[]' value='$SoundLevel2of3' size='7' onchange='funcEditValue(this.value)'></td>\n");
$SoundLevel3of3 = $RowCnt + 2;
echo("<td><input type='textbox' name='foo3of3[]' value='$SoundLevel3of3' size='7' onchange='funcEditValue(this.value)'></td>\n");
Code: Select all
if (isset($_POST['ProcessTextBoxes'])) {
$RowCnt=0;
//START: NOT FINISHED In here you need to place the same query that loads the table which shows on the form
// Currently only the fldMM_FirstName and other fields shown below are being loaded on the table.
// You never bothered to put the three SoundPot values in that file.
// You just wanted to find out if you could pick up all these values.
//END: NOT FINISHED In here you need to place the same query that loads the table
while($row = mysqli_fetch_array($result)) {
$fldKRP_Key = $row['fldKRP_Key'];
$fldKRP_Member_LU = $row['fldKRP_Member_LU'];
$fldMM_FirstName = $row['fldMM_FirstName'];
$fldMM_MiddleName = $row['fldMM_MiddleName'];
$fldMM_LastName = $row['fldMM_LastName'];
$fldKRP_InstrumentRecKey = $row['fldKRP_InstrumentRecKey'];
$fldIF_Name = $row['fldIF_Name'];
$SoundPot1of3 = $_POST['foo1of3'][$RowCnt]; //These commands get the data updates from the table
$SoundPot2of3 = $_POST['foo2of3'][$RowCnt];
$SoundPot3of3 = $_POST['foo3of3'][$RowCnt];
$RowCnt=$RowCnt + 1;
}
}