sodascape Posted November 11, 2006 Share Posted November 11, 2006 Like passing a kidney stone, i'm finding this difficult....I have a page with a form and a bunch of different checkboxes, I want to put all of the selected checkbox values into an array.... which I have done, but then I want to take that array and pass it to another page....so on the second page, it shows all of the values in that array.... can't seem to get it.Can you help?!?! Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/ Share on other sites More sharing options...
heckenschutze Posted November 11, 2006 Share Posted November 11, 2006 Well this is off the top of my head, but I think its right;Create the checkboxes like:[code]<form action="test.php" method="post"><input type="checkbox" name="myarray[]" value="Value 1"><br /><input type="checkbox" name="myarray[]" value="Value 2"><br /><input type="checkbox" name="myarray[]" value="Value 3"><br /><input type="checkbox" name="myarray[]" value="Value 4"><br /><input type="submit" value="test"></form>[/code]Then for debugging purposes:test.php[code]<?phpprint_r($_POST["myarray"]);?>[/code]hth :) Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123062 Share on other sites More sharing options...
sodascape Posted November 11, 2006 Author Share Posted November 11, 2006 Is that going to pass the ARRAY values from one page to another page, or does that just print out the values of the array? I can get it to do that, but I need the ARRAY created on one page and then listed on another page. Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123066 Share on other sites More sharing options...
Psycho Posted November 11, 2006 Share Posted November 11, 2006 How are you wanting to pass the values to another page: Form post, Session variable, on the URL??? Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123075 Share on other sites More sharing options...
sodascape Posted November 11, 2006 Author Share Posted November 11, 2006 A form on one page, with a bunch of CHECKBOX items, all of the selected CHECKBOX items are added to an array via the form......and then the ARRAY is sent to another page and on that page, the items of the array are displayed.EXAMPLE: Page 1 has "select colors" I pick out RED, GREEN and BLUE.... then I click the SUBMIT button and it takes me to the next page, and on Page 2 it says "You have selected the colors: RED GREEN AND BLUE. Make sense? Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123076 Share on other sites More sharing options...
joshi_v Posted November 11, 2006 Share Posted November 11, 2006 Well! You can't pass an array directly from one page to another page(this i came to know by this forum :( when i had the same problem!)If you are passing the values from one form to another..via POST ..there you can pass it.If in case you want to pass an array from one page to another page using URL ..before passing it you should make it as a string .like this[code]<?php$str=implode(",",$array);?>[/code]in next page you have to use explode function to form it as an array again!Third case if you want to pass it using a SESSION variable..simply assign it to a session variable.[code]<?php$_SESSION['name']=array()# you can assign it directly too..but in case if array had a single value in it..the this session will act as a string.$_SESSION['name']=$array;?>[/code]RegardsJoshi. Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123106 Share on other sites More sharing options...
Barand Posted November 11, 2006 Share Posted November 11, 2006 [quote author=sodascape link=topic=114615.msg466418#msg466418 date=1163235217]A form on one page, with a bunch of CHECKBOX items, all of the selected CHECKBOX items are added to an array via the form......and then the ARRAY is sent to another page and on that page, the items of the array are displayed.EXAMPLE: Page 1 has "select colors" I pick out RED, GREEN and BLUE.... then I click the SUBMIT button and it takes me to the next page, and on Page 2 it says "You have selected the colors: RED GREEN AND BLUE. Make sense?[/quote]That's basically what heckenschutze's code does Link to comment https://forums.phpfreaks.com/topic/26909-passing-arrays/#findComment-123132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.