By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

figure out which form was submitted out of dynamically created forms.

P: 5
Hey guys,

My main question is that can POST contain a variable instead of a string?

Im working on a problem with an application i am developing using html php and mysql. Part of the application im trying to develop consists of an inventory section. In this section the user can have multiple stores. Where im having difficulty is stock transaction.

How i have laid out this part of the application is that the user will click on a store from a list and a form will appear with a table consisting of all the items in that store which will be pulled from the database. Next to each item is a field to enter quantity and another field to enter any comments. after all the items are listed there is a submit button where form will be submitted.

As the number of stores is not predetermined, once the form is posted i have to come up with a way to find out which form is submitted. what i came up with was to list the stores again and create a loop which will check the number the store appears in the list, with the button that has been pressed (which i had named submit + the number in the list the store appears).

i.e.
store - number in list - name of submit button
store 1 - 0 - submit0
store 2 - 1 - submit1
store 3 - 2 - submit2
etc...

my theory is that i can use isset POST to find which button has been clicked, by creating a loop with a variable that will combine submit + the number of records in the store table in the database, i can find which form was submitted

i.e.
while $y<$x
$a = 'submit'.$a
if isset (POST($a))
...$y++

My main question is that can POST contain a variable instead of a string? I am beginning to think that it is not possible. is there any other way by which i can figure out which form was submitted out of the dynamically created forms.


Thanks alot for your time.
Nov 2 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.