HI guys,
I am making a dynamic list of buttons (number of buttons will change depending on how many people are in the list) and I want to have a button associated to each name. When the button is clicked I want a variable (the name) to be sent to another page. I cant get this working so maybe someone has some suggestions...
code:
<?php
for ($print_command=1;$print_command<$command_index;$print_command++){
?>
<tr>
<td ><? echo"$name[$print_command]";?> </td>
<td ><input type="button" onclick="window.location='info.php' " value="View Profile"></td>
</tr>
<?
}
?>
How do I send the $name[$print_command] to the info.php page....... my object is to create a list of names and next to each name there will be a button. If the button is clicked then the specif information for that person will be displayed in an iframe. any suggestions are appreciated and thanks again for the help.
[SOLVED] dynamic buttons
Moderator: General Moderators
add the id or whatever you use to link the butto the record into the onclick
Then use $_GET['id'] on the info.php page to get that value and query on it to get the particular data
Code: Select all
<input type="button" onclick="window.location='info.php?id=".$name[$print_command]."' value="View Profile"></td>