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