Forum Moderators: coopster
Here's the issue: I'm pulling a table of information into a page via php. Each row contains a headline, body text and author.
Next to each row, the boss wants a REGULAR button that says Edit, and then another REGULAR button that says Delete.
I'm succesful at passing the correct row id using single radio button beside each row with a Delete (submit) or Edit (submit) button at the bottom of the page.
But, the boss don't want that. He wants each row to have two regular buttons beside each row.
Of course, if I set the value of these regular buttons to my row id, the buttons display the row id rather than "Delete" or "Edit" as required.
So...does anyone know of a way to keep the Delete or Edit label of these two buttons which, when pressed, would pass the correct value of the row they are adjescent (sp?) to?
I've thought about using hidden fields which would contain the row id numbers, but am not sure how to reference them once either of the two buttons were pressed.
Any and all help greatly appreciated.
Neophyte
Wrap it all up in a table so it looks nice for your boss. Give me a little bit of the raise that you get when you explain what a difficult technical problem you were able to solve :)
WBF
Bosses can really be a pain, huh? Not to worry, there is a solution.
Use the name attribute of the submit buttons to determine what was clicked.
Example
<input type="submit" name="edit_1032" value="edit" />
<input type="submit" name="delete_1032" value="delete" />
In your PHP script...
foreach($_POST as $key => $val){
if ($val == "edit"){
$arr = explode("_", $key);
$id = $arr[1]; // THIS IS YOUR ITEM TO DEAL WITH(1032 in this case)
...add edit code here...
}
if ($val == "delete"){
$arr = explode("_", $key);
$id = $arr[1]; // THIS IS YOUR ITEM TO DEAL WITH(1032 in this case)
...add delete code here...
}
}
Hope that helps out...
Thanks so much for your assistance - Birdman's recommondation of splitting the value of each button into the button name and row value ... and then using the explode() function ... worked like a charm!
Of course, my boss isn't impressed (he's never impressed); his only response was "yeah, that's what I mean ... why didn't you get that done a week ago?"
Such is life.
Neophyte