|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Assign a variable to an infinite number of items of a form to a processing page.
I select a dynamic number of CATEGORIES to a page.
while (ocifetch($curser)){ echo "<INPUT TYPE=text name ="$category_value"> } Ok here is the thing, I do not know the number of CATEGORIES there are. So how do I assign a variable to each value from the form. foreach value in page A, get that variable on page B. I know that if I new the exact CATEGORY's I could select them out of the DB using the unique name of the CATEGORY as the form name. On pageB I would say $category1 = $_POST['category_name']; $category2 = $_POST['category_name']; so on....... I do not know the number of the categories that will be displayed on page A, untill it is pulled from the DB. So how will I know the number od varible to use on page B, and how do I assign the values of $_POST[] to them? Each CATEGORY may of may not have a weight assigned to it. Any ideas will be GREATLY accepted! |
|
#2
|
||||
|
||||
|
The way I've often handled this in the past is to assign a prefix to a given group of fields. So all fields that represent fields might be named "cat_<something>" where <something> is the database result. Then you can iterate over your $_POST vars and look for fields whose name begins with "cat_" to determine which ones are categories. No need to assign additional variables on page B -- just use the $_POST array.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
That worked perfect. I just did a while(list(($key, As $value) each($_POST)));
The syntax may not be right here in this example but that is the concept I used to get the Form name and Value. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Assign a variable to an infinite number of items of a form to a processing page. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|