Jump to content

implode function not working


tonyledenko

Recommended Posts

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]);

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/123969-implode-function-not-working/
Share on other sites

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>

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>

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.

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.