Re: classes?

From: Date: Thu, 16 Nov 2000 06:22:09 +0000
Subject: Re: classes?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25626@lists.php.net to get a copy of this message
At 01:17 AM 11/16/2000 -0500, Ignacio Vazquez-Abrams wrote:
On Thu, 16 Nov 2000, Kurth Bemis wrote: ok all i'm just starting to get involved with classes...and have a slight problem......i don't understand how to access functions..i have been reading the manual at php.net but that confuses even more....take a look at some code i wrote... print "<a href=\"$PHP_SELF?product=$product&quanity=1\">$title - $price</a>"; thats to add a item to my cart...... the class function looks like this...
         function add_item($table, $session, $product, $quantity) {
             $qty = $this->check_item($table, $session, $product);
             if($qty == 0) {
                 $query = "INSERT INTO $table (session, product, quantity)
VALUES ";
                 $query .= "('$session', '$product', '$quantity') ";
                 mysql_query($query);
             } else {
                 $quantity += $qty;
                 $query = "UPDATE $table SET quantity='$quantity' WHERE
session='$session' AND ";
                 $query .= "product='$product' ";
                 mysql_query($query);
             }
         }
my question is how to i pass that vars that i need to the class? am i making sense here? ~kurth Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer There is no sin except stupidity. -- Oscar Wilde kurth@usaexpress.net | http://www.usaexpress.net/kurth PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net) First of all, don't use $PHP_SELF when dealing with things as vital as a shopping cart. Use a form with a method of POST. Then, have the action go to a second script where you use $HTTP_POST_VARS to retrieve the variables and add the item, then emit a "Location:" header to bounce back to the original script.
ok...what about referring to the class - am i doing that correctly?
-- Ignacio Vazquez-Abrams <ignacio@openservices.net>
Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer There is no sin except stupidity. -- Oscar Wilde kurth@usaexpress.net | http://www.usaexpress.net/kurth PGP key available - http://www.usaexpress.net/kurth/pgp Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net (http://www.distributed.net)

« previous php.general (#25626) next »