Actually I have an array with the names of the files, I display it in the following form

<b>Список файлов:</b><br><br> <form method="post" action=""> <table width="100%" border="1"> <tbody><tr><td width="80%"> _samoe_nujnoe_o_prirodnyih_vodah_-_chast_1 </td><td width="15%"><center> <input id="refresh" name="refresh" value="Обработать" type="submit"></center> </td></tr></tbody></table> <table width="100%" border="1"> <tbody><tr><td width="80%"> _samoe_nujnoe_o_prirodnyih_vodah_-_chast_2 </td><td width="15%"><center> <input id="refresh" name="refresh" value="Обработать" type="submit"></center> </td></tr></tbody></table> ----------------------------------------- <table width="100%" border="1"> <tbody><tr><td width="80%"> _samoe_nujnoe_o_prirodnyih_vodah_-_chast_N </td><td width="15%"><center> <input id="refresh" name="refresh" value="Обработать" type="submit"></center> </td></tr></tbody></table> </form> 

the appearance of this etogo something like this: http://xatak.ru/aaaaa.JPG

the question is how to correctly write down the attributes of the buttons, that when you click on one of them, a variable was transferred, for example FileName and it had a value from the first column of the table ... the file name in the first column is displayed in the variable $ file ...

    2 answers 2

    If I understood correctly...

     <form method="post" action=""> <table width="100%" border="1"> <tbody> <tr> <td width="80%"> <span>имя файла</span> <input type='hidden' name='filename' value='имя файла'> </td> <td width="15%"> <input id="refresh" name="refresh" value="Обработать" type="submit"> </td> </tr> </tbody> </table> </form> 
    • thanks! what you need! - arashvg
    • In this variant, the last file name will always be transmitted, and not whose button was pressed .. - Photon
    • You can wrap each table in the form, then it will be what you need. - ReklatsMasters

    List output:

     <?php $files = [ "file1", "file2", "file3" ]; ?> <b>Список файлов:</b><br><br> <form method="post" action="process.php"> <?php foreach($files as $key=>$file): ?> <table width="100%" border="1"> <tbody> <tr> <td width="80%"><?=$file;?></td> <td width="15%"> <center> <input type="hidden" name="file[]" value="<?=$file;?>" /> <input name="refresh[<?=$key;?>]" value="Refresh" type="submit"> </center> </td> </tr> </tbody> </table> <?php endforeach; ?> </form> ?> 

    Processing (example):

     <?php $keys = array_keys($_POST['refresh']); $key = array_pop($keys); echo $_POST['file'][$key]; ?>