Forum Moderators: coopster
print"<td align='center'><input type=submit name=Update_$aRowId value=Edit></td>";
--------------
When I click this button, another page is loaded. In this second page, I use the explode function to pick apart the $_POST array like this:
foreach($_POST as $key => $val){
$arr = explode("_", $key);
$buttonHit=$arr[0];
$rowId=$arr[1];
}
--------------
When I do a test print to make sure my array elements are there...
print "Button Hit is $buttonHit, Row Id is $rowId";
... everything is fine: "Button hit is Update, Row Id is 13
--------------
BUT, now I want to pass one more argument for a table name. So I alter my button name to read:
<input type=submit name=Update_$aRowId_$aTable value=Edit>
NOTE: "article" is the value within $aTable.
The explode function now looks like this:
foreach($_POST as $key => $val){
$arr = explode("_", $key);
$buttonHit=$arr[0];
$rowId=$arr[1];
$table=$arr[2];
}
--------------
When I test this with the following print statement:
"Button Hit is $buttonHit, Row Id is $rowId", and Table affected is $table";
Here's what I get:
Button Hit is Update, Row Id is article, Table is
Huh?
--------------
The first value "Update" is correct, the second value should be a row number (but, instead, it's "article"), and the third value should be "article", but nothing shows up at all.
Beating my head against the wall on this. What am I doing wrong? I looked in the php manual and explode can use a whole bunch of string elements, so it's obviously me (what a surprise).
Can someone please tell me how to make this work?
Neophyte
...name=Update_$aRowId."_".$aTable value=...
I hope this helps.
PS: When developing, turn your error reporting up to
error_reporting(E_ALL); and you will get undefined variable notices to help you spot problems like this.