Jump to content

Recommended Posts

Could someone tell me how to print out each element of $_Session['order'] so that the output looks like:

pose
quantity
size
finish

pose
quantity
size
finish

Is there something wrong with

$formArray=array($pose,$quantity,$size,$finish);
array_push($_SESSION['order'],$formArray);

foreach ($_SESSION['order'] as $tempArray)
{
print $tempArray[0] . "<br />\n";
print $tempArray[1] . "<br />\n";
print $tempArray[2] . "<br />\n";
print $tempArray[3] . "<br />\n";
print "<br />";
}


[code=php:0]
session_start();

$_SESSION['order'];
$_SESSION['totalPrice'];
$_SESSION['basicCost'];
$_SESSION['finishUpgrade'];
$_SESSION['totalBasicPoints'];
$_SESSION['productNumber'];
if (array_key_exists('_submit_check', $_POST)) {

$pose = $_POST['pose'];
$quantity = $_POST['quantity'];
$size = $_POST['size'];
$finish = $_POST['finish'];
$gallery = $_POST['gallery'];
$retouch = $_POST['retouch'];
$cards = $_POST['cards'];
$proofs = $_POST['proofs'];

$formArray=array($pose,$quantity,$size,$finish);
array_push($_SESSION['order'],$formArray);

foreach ($_SESSION['order'] as $tempArray)
{
print $tempArray[0] . "<br />\n";
print $tempArray[1] . "<br />\n";
print $tempArray[2] . "<br />\n";
print $tempArray[3] . "<br />\n";
print "<br />";
}

$_SESSION["productNumber"] += 1;

include 'sizeCase.php';
$basicPoints*=$quantity;

include 'finishCase.php';

$_SESSION['finishUpgrade']*=10;
$_SESSION['upgradedPrice']= $_SESSION['finishUpgrade'] + $basicCost;

$_SESSION['totalBasicPoints'] += $basicPoints;

$basicPoints = $_SESSION['totalBasicPoints'];
$extraPoint = 0;

include 'packageCase.php';

$_SESSION['basicCost'] = $basicCost;
$_SESSION['extraPoint'] = $extraPoint;
$_SESSION['upgradedPrice']= $_SESSION['finishUpgrade'] + $basicCost;


print "total Basic Points are ". $_SESSION['totalBasicPoints'] ."<br />\n";
print "productNumber is ". $_SESSION["productNumber"] ."<br />\n";
print "totalPrice is ". $_SESSION['totalPrice'] ."<br /> \n";
print "basic Price is ". $_SESSION['basicCost'] ."<br /> \n";
print "Finish Upgrade is ". $_SESSION['finishUpgrade'] ."<br /> \n";
print "You get " .$_SESSION['extraPoint']. " extra points. <br />\n";
print "The Upgraded Cost is ". $_SESSION['upgradedPrice']. "<br />\n";

}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6152-printing-out-arrays/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.