Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 21st, 2006, 05:19 PM
Registered User
 
Join Date: Sep 2006
Location: woodstock, ontario, Canada.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default number problem

Working on the online shopping cart and testing it out, I've noticed that if you add 1 item and jack up the quantity enough to put the price total OVER $1000, the price doesn't translate well...

but if you add multiple items and have them equal over $1000 the math works fine...

can anyone help?

Thanks a lot,
Kyle

  #2 (permalink)  
Old October 16th, 2006, 03:29 PM
Registered User
 
Join Date: Oct 2006
Location: Tampa, Fl, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi:
Here is a way to solve the $total shopping cart problem.



1) you will need to add a new field to the cartemp table.

carttemp_price


 2) add the following in to getprod.php

this will be in the add to cart form.

<input type="hidden" name="products_price"
          value="<?php echo $products_price ?>">

3) add this line to modcart.php

if (isset($_POST['products_price'])) {

$price = $_POST['products_price'];

}

now change the query that add a product to the carttemp table

 case "add":
    $query = "INSERT INTO carttemp (
              carttemp_sess,
              carttemp_quan,
              carttemp_price,
              carttemp_prodnum
              )
              VALUES ('$sess','$qty','$price','$prodnum')";


4) Add the following to the cart.php file

$query1 = "SELECT SUM(carttemp_price * carttemp_quan) AS total_amount FROM carttemp WHERE carttemp_sess = '$sessid'";
$results1 = mysql_query($query1)
  or die ('error');



while ($rows1 = mysql_fetch_array($results1))
{
$total_amount = $rows1['total_amount'];

}



5) add the following line to cart.php where the total is calculated..

Your total before shipping is:</td>
    <td align=\"right\">$<?php echo number_format($total_amount, 2); ?></td>

this line will replace ---->


Your total before shipping is:</td>
    <td align=\"right\"> <?php echo $total; ?></td>


Now you are all set.. make similar changes to checkout3.php when calculating the totals..

but this solves that pesky cart total issue.. and you can add as many products and prices as you like!



  #3 (permalink)  
Old July 31st, 2008, 05:57 PM
Registered User
 
Join Date: Jul 2008
Location: lagos, lagos, Nigeria.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANKS A MILLION ON YOUR CONCLUSION FOR THIS TOPIC.
IT REALLY WORKED.
YOU ARE ONE OF THE BEST IN HERE.
TGAMER


Similar Threads
Thread Thread Starter Forum Replies Last Post
number problem zetor C# 1 March 7th, 2007 12:03 PM
problem with Auto Number Brendan Bartley Access 6 August 14th, 2006 10:13 AM
Problem to Swap two number in C# furqanms C# 1 June 5th, 2006 05:12 PM
Number precision problem adriant42 Excel VBA 2 June 28th, 2004 01:00 PM
Error Number Problem momowu0701 VB.NET 2002/2003 Basics 2 March 4th, 2004 12:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.