Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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

Reply With Quote
  #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!



Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.