tonyledenko Posted September 12, 2008 Share Posted September 12, 2008 Hello, I am trying to pass multiple values, via an implode function. However, it isnt working. Here is the code from the first page, then the second page. <?php if(isset($_POST['numItems'])) { $checkboxes = $_POST['numItems']; $string = implode($value,"^"); echo $string; } ?> <form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'> <input type='checkbox' name='numItems[]' value='RAM-VB-162'> <input type='checkbox' name='numItems[]' value='RAM-VB-154'> <input type='submit' value='Add To Cart'> </form> Second Page: <?php include_once('./CartDBCxn.php'); if (!isset($_COOKIE['sess'])) { session_start(); $usrSession = session_id(); setcookie('sess',$usrSession,0,'/','ram-mount.com'); } else { $usrSession = $_COOKIE['sess']; } if (isset($_GET['act'])) { if ($_GET['act'] == 'remove') { removeCartItem($_GET['part'],$usrSession); } } if (isset($_POST['numItems'])) { // Process the update code $numItems = $_POST['numItems']; $items = $_POST; echo ("\n\n\n <!-- "); print_r($_POST); echo (" --> \n\n\n"); for ($x=0;$x < $numItems; $x++) { $itm = 'item'.($x+1); $quan = 'Qty'.($x+1); changeCartItem($items[$itm],$usrSession,$items[$quan]); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/ Share on other sites More sharing options...
BlueSkyIS Posted September 12, 2008 Share Posted September 12, 2008 where do you set $value to an array? Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639927 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 Use implode("^",$value); not implode($value,"^"); Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639928 Share on other sites More sharing options...
tonyledenko Posted September 12, 2008 Author Share Posted September 12, 2008 Unfortunately that didn't work. Any other suggestions? Thanks. <?php if(isset($_POST['numItems'])) { $checkboxes = $_POST['numItems']; $string = implode("^",$value); echo $string; } ?> <form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'> <input type='checkbox' name='numItems[]' value='RAM-VB-162'> <input type='checkbox' name='numItems[]' value='RAM-VB-154'> <input type='submit' value='Add To Cart'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639937 Share on other sites More sharing options...
tonyledenko Posted September 12, 2008 Author Share Posted September 12, 2008 If I do the following then the cart updates; however I want to provide the user a choice based on check boxes. <form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'> <input type='hidden' name='part' value='RAM-VB-154^RAM-VB-162'><input type='submit' value='Add To Cart'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639938 Share on other sites More sharing options...
wildteen88 Posted September 12, 2008 Share Posted September 12, 2008 Unfortunately that didn't work. Any other suggestions? Thanks. <?php if(isset($_POST['numItems'])) { $checkboxes = $_POST['numItems']; $string = implode("^",$value); echo $string; } ?> <form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'> <input type='checkbox' name='numItems[]' value='RAM-VB-162'> <input type='checkbox' name='numItems[]' value='RAM-VB-154'> <input type='submit' value='Add To Cart'> </form> $value should be $checkboxes. Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639941 Share on other sites More sharing options...
tonyledenko Posted September 12, 2008 Author Share Posted September 12, 2008 Almost worked! One of the two values passed through, the RAM-VB-154 Here is the page online: http://www.ram-mount.com/wizards/test.php Any suggestions on how to push both values through? Thanks <?php if(isset($_POST['part'])) { $checkboxes = $_POST['part']; $string = implode("^",$checkboxes); echo $string; } ?> <form name='CartItem' action='https://www.ram-mount.com/RamCart/CartPutItem.php' method='POST'> <input type='checkbox' name='part' value='RAM-VB-162'> <input type='checkbox' name='part' value='RAM-VB-154'> <input type='submit' value='Add To Cart'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/123969-implode-function-not-working/#findComment-639954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.