[PHP] Multidimensional Array...

2001-10-18 Thread Roy van Pelt

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!!)
=
 '', '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"."\n";
  var_dump($offer)."\n";
  echo "back";
}
//else print the contents of the offer
  else
{
for ($i=0; $i<$nrItems; $i=$i+1)
{
  echo "The offer:"."\n";

  var_dump($offer)."\n";

  echo "The offer contains items: ";
  echo $nrItems."\n";
  echo $offer[$i]['pid']."\n";
  echo $offer[$i]['pname']."\n";
  echo $offer[$i]['pqty']."\n";
  echo "\n";
  echo "back";
  echo "\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]




[PHP] Posted this a few day ago, really need help :S (arrays)

2001-10-20 Thread Roy van Pelt

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!!)
=
 '', '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"."\n";
  var_dump($offer)."\n";
  echo "back";
}
//else print the contents of the offer
  else
{
for ($i=0; $i<$nrItems; $i=$i+1)
{
  echo "The offer:"."\n";

  var_dump($offer)."\n";

  echo "The offer contains items: ";
  echo $nrItems."\n";
  echo $offer[$i]['pid']."\n";
  echo $offer[$i]['pname']."\n";
  echo $offer[$i]['pqty']."\n";
  echo "\n";
  echo "back";
  echo "\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]