peet1909 Posted July 11, 2008 Share Posted July 11, 2008 I need a PHP grid that loads data from a mySQL table into agrid and adds a button on each row as well. When this button is pressed, the ID of that row (which in this case would be column1), would be passed back as a session or post or something for me to process. Please help me - I have searched and tried a lot of 3rd party grids with no success. ??? Quote Link to comment Share on other sites More sharing options...
mbeals Posted July 11, 2008 Share Posted July 11, 2008 So you want a table with a button on each row such that when you press the button it submits just that one row? Build your table and populate the rows with a button at the end of every row. Give the button whatever value you want, but dynamically give each button a unique name corresponding to the 'row id'. When you submit this form, your $_POST array will contain the info from the button pressed to submit the form. Since it has a unique name, you know with button was pressed even though you have many on the same form. Here's an example: <?php if(isset($_POST)) print_r($_POST); $query = "" // put query here $result = mysql($query); ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST" name="tableData"> <table> <tr> <td>Col 1</td> <td>Col 2</td> <td>Col 3</td> <td> </td> </tr> <?php while($row = mysql_fetch_array($result)){ ?> <tr> <td><?=$row['col1']?></td> <td><?=$row['col2']?></td> <td><?=$row['col3']?></td> <td><input name="<?=$row['index']?>" type="submit" value="Submit"/></td> </tr> <? } ?> </table> </form> if you insert some database code and change the values in the while block to match, that script will build a table of the rows returned by the query with a submit button at the end. Click on different buttons and see what happens. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.