You are here: Re: Getting quantity input for each product in a product/price associative array « PHP Language « IT news, forums, messages
Re: Getting quantity input for each product in a product/price associative array

Posted by Ryan on 01/03/07 03:19

The only problem with that, is I'm trying to stay within the guidelines
of where I am in the book. It appears I'm having trouble just sending
data in an array from one site to another. I take it using the html
'sumbit' won't work in a php script? I tried using regular arrays to
store price, names, and the quantity the user inputs, but when I try to
echo any of that into the process.php script, nothing displays. It's
not a huge ordeal, I just though I'd try update my pages as I go along
with the book. Thanks though!

Jussist wrote:
> Now this is a perfect place to go OO. Instead of having those weird
> associative arrays, use objects.
>
> <?php
> class Prodcuct {
> $name;
> $price;
> }
> ?>
> <?php
> class CartItem {
> $product;
> $quantity;
> }
> ?>
> <?php
> $newProductToCart = new CartItem();
> $newProductToCart->setProduct($myProduct);
> $newProductToCart->setAmount(5);
> $MyCart[] = $newProductToCart;
> ?>
> <?php
> for($i=0;$i<count($MyCart);$i++) {
> echo "Product:" . $MyCart[$i]->getProduct()->getName() . " - " .
> $MyCart[$i]->getAmount();
> }
> ?>
>
> That's the general idea anyway.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация