Re: function not working?

From: Date: Wed, 28 Feb 2001 15:38:47 +0000
Subject: Re: function not working?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42037@lists.php.net to get a copy of this message
your function function display_contents($table,$session) { $count = 0; $result = mysql_query( "SELECT * FROM $table WHERE session = '$session'"); while($row = mysql_fetch_array($result)) { $result_inv = mysql_query( "SELECT * FROM retailseafood WHERE pid = '{$row['items']}' "); $row_inventory = mysql_fetch_array($result_inv); $contents['items'][$count] = $row_inventory['pid']; $contents['price'][$count] = $row_inventory['price']; $contents['total'][$count] = $row_inventory['price'] * $row['quantity']; $count ++; } $total = $this->cart_total($table, $session); $contents['final'] = $total; return $contents; } looks ok, there are some code snippits missing ($this->cart_total()) but I'll assume its rudamentry. the code you are missing is how your accually calling your function <a href="cart.php?action=display">View Contents Of Cart</A> is a url, you forgot to include the src of cart.php to see where you are accually calling the function. cart.php <?php if ($action == 'display') display_contents('some_table', $sessionID); ?> please email me if you have more questions or comments. -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 lee@mediawaveonline.com "Kurth Bemis" <kurth@usaexpress.net> wrote in message news:4.3.2.7.2.20010228022417.01763ad8@mail.usaexpress.net... i can't get his function to work. i pass the correct data to it...but no results.... heres the function function display_contents($table,$session) { $count = 0; $result = mysql_query( "SELECT * FROM $table WHERE session='$session'"); while($row = mysql_fetch_array($result)){ $result_inv = mysql_query( "SELECT * FROM retailseafood WHERE pid='$row[items]'"); $row_inventory = mysql_fetch_array($result_inv); $contents[ "items"][$count] = $row_inventory[pid]; $contents[ "price"][$count] = $row_inventory[price]; //$contents[ "quantity"][$count] = $row[quantity]; $contents[ "total"][$count] = ($row_inventory[price] * $row[quantity]); $count ++; } $total = $this->cart_total($table,$session); $contents[ "final"] = $total; return $contents; } // return number of items in cart and heres what i do to call the function <A href="cart.php?action=display">View Contents Of Cart</A> what or where am i doing/going wrong? ~kurth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#42037) next »