php - Get html button id and store it for next page -


ok, there anyway button id when clicked , store use in next page (i'm trying use button id know button clicked , use sql query in next page) ? here's code :

        while($donnees=$reponse->fetch())         {           ?>                         <tr>                             <form action="suppression.php" method="post">                                 <td ><h3 ><a ><?php echo $donnees['ncheque']; ?></a></h3></td>                                 <td><?php echo $donnees['dateremise'];?></td>                                 <td><a><?php echo $donnees['client'];?></a></td>                                 <td><a><?php echo $donnees['banque'];?></a></td>                                 <td><a><?php echo $donnees['motif'];?></a></td>                                 <td><?php echo $donnees['dateretour'];?></td>                                 <td><?php echo $donnees['datedelivrance'];?></td>                                                                    <td><input type="submit" id="<?php echo $donnees['ncheque'] ?>" class="button" name="delete" value="supprimer" /><a href="#" class="ico modifier">modifier</a></td>                              </form>                          </tr>             <?php          }         $reponse->closecursor();         ?> 

you should wrap each button in <form> element , specify parameter directly in action in php check button clicked using $_get.

first page

<form action='otherpage.php?button=button1'><button>button1</button><form> <form action='otherpage.php?button=button2'><button>button2</button><form> 

second page

<?php if($_get['button']=="button1"){   echo "button 1 clicked"; } else if($get['button']=="button2"){   echo "button 2 clicked"; } else {   echo "no button clicked"; } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -