PHP - passing a variable from a repeated region?

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
Ender22
Forum Newbie
Posts: 8
Joined: Thu Apr 12, 2007 11:15 am

PHP - passing a variable from a repeated region?

Post by Ender22 »

Hey, I need a little help here.
I'll try to explain what im trying to do as best as I can.

I have a repeated region with a 'Name' a 'ID' and a 'Submit' button

Repeated Region
------------------------------------------------
{Recordset1.Name}, {Recordset1.ID} | SUBMIT |
------------------------------------------------

so on my page I see every name next to every ID in my database and each one has their own submit button.

Now what I need to do is on Submit pass the specific ID of the row in the table for which the submit button was pressed.

For example if they scroll down to the 5 element in the repeated region (with ID 5) and they hit Submit I need to pass the number 5 to a function.

I understand that you cant call a php function from a button press so I have been trying to do this with the
if(isset($_POST['submit']))
{
// do whatever with the variable.
}

statement.

Does anyone know how I can do this properly?

THANKS!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You could give each button its own name, then loop through the potential names for isset. Although, what I have done is made each row its own form and checked for the submitted user id.
Ender22
Forum Newbie
Posts: 8
Joined: Thu Apr 12, 2007 11:15 am

Post by Ender22 »

Ahh.. thank you so much!
I went with the second option.
Thanks for the help :D
Post Reply