Page 1 of 1

dynamic buttons

Posted: Mon Aug 16, 2004 12:56 pm
by LTLhawk
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.

Posted: Mon Aug 16, 2004 2:08 pm
by lostboy
add the id or whatever you use to link the butto the record into the onclick

Code: Select all

<input type="button" onclick="window.location='info.php?id=".$name[$print_command]."' value="View Profile"></td>
Then use $_GET['id'] on the info.php page to get that value and query on it to get the particular data

Posted: Tue Aug 17, 2004 6:06 am
by LTLhawk
worked like a charm...thank you very much.. learned a lot today... : )