Thanks Curt AND Ralph, This makes it all a lot more clear and easy to understand. And yes, it makes sense. I'll try it now and see what happens.
What I've never seen before is what you did with: if($row = mysql_fetch_array($result)) that made me go LOL!!! Thanks in advanced, Cesar Aracena www.icaam.com.ar > > I agree with Curt, use mySQL to get the sum of 'sess_itemsize' then > divide the result by size per disk to get quantity. So your function > should look something like this: > > function cart_cdqty() > { > > $query = "SELECT SUM(sess_itemsize) AS total_size > FROM sessions > WHERE sess_id = ".$_COOKIE['SID'].""; > > $result = mysql_query($query); > > if($row = mysql_fetch_array($result)) > { > $n = $row['total_size']; > $x = ceil( $n / 690.0 ); > > $cart_cdqty = array( > 'quantity' => '$x', > 'total_size' => '$n', > ); > > return $cart_cdqty; > } else { > return false; > } > > } > > Then all you do is call the function like this: > > if(!$cdqty = cart_cdqty()) > { > print 'no items found in your shopping cart'; > } else { > print 'Total Size:' . $cdqty['quantity'] . '<BR>'; > print 'Total CDs:' . $cdqty['total_size'] . 'MBs <BR>'; > } > > I have not tested this but it should work. > > Ralph > > -----Original Message----- > From: Cesar Aracena [mailto:[EMAIL PROTECTED] > Sent: Monday, August 18, 2003 8:54 PM > To: 'Ralph Guzman'; [EMAIL PROTECTED] > Subject: RE: [PHP] Delimiter WITHOUT lots of IF's > Importance: High > Sensitivity: Confidential > > Ok. Here you have the entire function to see how many CD's the order > will contain: > > function cart_cdqty() > { > $query = "SELECT * FROM sessions WHERE sess_sid = > ".$_COOKIE['SID'].""; > $result = mysql_query($query); > $num_rows = mysql_num_rows($result); > > $x = 0; > $n = 0; > > for ($y = 0; $y < $num_rows; $y++) > { > $row = mysql_fetch_array($result); > $n = $n + $row[sess_itemsize]; > } > > if ($n > 0 AND $n <= 690.0) { > $x = 1; > } elseif ($n > 690.1 AND $n <= 1380.0) { > $x = 2; > } elseif ($n > 1380.1 AND $n <= 2070.0) { > $x = 3; > } elseif ($n > 2070.1 AND $n <= 2760.0) { > $x = 4; > } elseif ($n > 2760.1 AND $n <= 3450.0) { > $x = 5; > } > > return $x; > } > > Pretty long if someone wants to order 17MBs don't you agree? > > Thanks for this, > > Cesar Aracena > > > > > No, that sounds about right. > > > > So your table should have the following fields: > > > > customer_session_id, item_id, quantity, final_price > > > > so then all you have to do is query this table looking for all items > in > > customers shopping cart. > > > > I am not quite sure how you are going about calculating orders in > > customer's basket. You said you wrote a function with multiple IF > > statements, can you show me the code for this function so that I can > get > > a better idea of what you are currently doing? > > > > > > -----Original Message----- > > From: Cesar Aracena [mailto:[EMAIL PROTECTED] > > Sent: Monday, August 18, 2003 8:38 PM > > To: 'Ralph Guzman'; [EMAIL PROTECTED] > > Subject: RE: [PHP] Delimiter WITHOUT lots of IF's > > Importance: High > > Sensitivity: Confidential > > > > Using a cookie (I know, I know...) I plant a cookie in the visitor's > > browser when he opens the site with a random generated number which > > expires when the browser(s) is closed. With that SID, PHP stores the > > orders (one per line) into a "sessions" table in MySQL each with the > > itemID. Is it fine or am I too messy? > > > > TXS, > > > > Cesar Aracena > > > > > > > > How are you keeping track of items added being added to the shopping > > > cart? > > > > > > -----Original Message----- > > > From: Cesar Aracena [mailto:[EMAIL PROTECTED] > > > Sent: Monday, August 18, 2003 7:55 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] Delimiter WITHOUT lots of IF's > > > Importance: High > > > Sensitivity: Confidential > > > > > > Hi all, > > > > > > I need to create an automatic process for visitors who are adding > > items > > > into a shopping cart, be able to see how many MBs and how many CDs > > will > > > the order have. > > > > > > >From this site, visitors will be able to choose one ore more > software > > > products from a list of hundreds. I want them to check the cart to > see > > > something like: > > > > > > Total size: 872,43 MBs > > > Total CDs: 2 > > > Total price: $XXX,XX > > > > > > Now, I developed a decision function that works with a lot of IF > > > statements, but I only calculated a max o 6 CDs (690,00 MBs max. per > > > CD), but I want to be able to make this automatically... Can someone > > > help me with this? > > > > > > BTW, Using PHP 4+ and MySQL 3+. > > > > > > Thanks in advanced, > > > > > > Cesar Aracena > > > www.icaam.com.ar > > > > > > Note: The information inside this message and also in the attached > > files > > > might be confidential. If you are not the desired receptor or the > > person > > > responsible of delivering the message, we notify you that it's copy, > > > distribution, keep or illegal use of the information it has it's > > > prohibited. Therefore we ask you to notify the sender by replying > this > > > message immediately and then delete it from your computer. > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php