Hello there...

The problem is that I can only add one value into the array...
Anyone knows what I'm doing wrong here....(First project by the way!!)
=====================================================
<?php
  session_start();
  session_register("offer");

// Make a new offer if it doesn't exist yet
if (!is_array($offer))
{
  $offer = array(array('pid' => '', 'pname' => '', 'pqty' => ''));
  $nrItems = 0;
}

// Get variables from products.php
$productID=trim(${"pid"});
$productName=trim(${"productName"});

// Add product to offer
if ($productID!="")
{
    $nrItems = $nrItems + 1;
    for ($i=0; $i<$nrItems; $i=$i+1)
    {
      if ($offer[$i]['pid']=="")
      {
   $productQTY = 1;
   $offer[$i]['pid'] = $productID;
   $offer[$i]['pname'] = $productName;
   $offer[$i]['pqty'] = $productQTY;
      }
    }
}

//if there are no items in the offer, print a message
if ($offer[0]['pid']=="")
{
  echo "No items in the offer"."<br>\n";
  var_dump($offer)."<br>\n";
  echo "<a href=producten.php>back</a>";
}
//else print the contents of the offer
  else
{
for ($i=0; $i<$nrItems; $i=$i+1)
{
  echo "The offer:"."<br>\n";

  var_dump($offer)."<br>\n";

  echo "The offer contains items: ";
  echo $nrItems."<br>\n";
  echo $offer[$i]['pid']."<br>\n";
  echo $offer[$i]['pname']."<br>\n";
  echo $offer[$i]['pqty']."<br>\n";
  echo "<br>\n";
  echo "<a href=producten.php>back</a>";
  echo "<br>\n";
}
}
======================================================

THNX in advance






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to