[SOLVED] dynamic buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LTLhawk
Forum Newbie
Posts: 4
Joined: Mon Aug 16, 2004 12:56 pm

dynamic buttons

Post 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.
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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
LTLhawk
Forum Newbie
Posts: 4
Joined: Mon Aug 16, 2004 12:56 pm

Post by LTLhawk »

worked like a charm...thank you very much.. learned a lot today... : )
Post Reply