Current location: Hot Scripts Forums » Programming Languages » PHP » * Shopping Cart In Php *


* Shopping Cart In Php *

Reply
  #1 (permalink)  
Old 09-21-03, 01:18 PM
nabi nabi is offline
Newbie Coder
 
Join Date: Sep 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Question * Shopping Cart In Php *

hi

i was wondering if anyone knew how to do calculations in php?
i want to use this to design my first shopping cart.

e.g. when a user clicks on a checkbox, it will automatically recognise that the item is e.g. $30 and then if/when a user clicks on another item which is e.g. $50, the script will add up the $30 + $50 and send it to the url or somewhere else if possible.

i am a beginner in programming so please can you help me with this as i would be very grateful, if you cant help me solve this problem then can you please tell me where i can find a free, good and easy to program paypal shopping cart?
Reply With Quote
  #2 (permalink)  
Old 09-21-03, 07:14 PM
Patriarch Patriarch is offline
Newbie Coder
 
Join Date: Sep 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
- Nabi

If you want to go the easy route, check http://www.hotscripts.com for several free PHP/MySQL shopping cart scripts.

But that's cheating, and besides, what better way to know how your cart works than by getting your hands dirty and building it yourself?

I won't go over it all, but in regards to your question, what you can do is set up a MySQL database table with all the items and their prices.

After that, query the database, and then output it in an html form:

PHP Code:

<form action="calculate.php" method="post">

<?php
$qry_items 
mysql_query('SELECT item, cost FROM tbl_items');
while (
$rst_items mysql_fetch_array($qry_items)) {
?>
<input type="checkbox" name="price" value="<?= $rst_items['cost']; ?>" /> - <?= $rst_items['item']; ?><br />
<?php
}
?>
</form>
After the user submits the form, all you need to do is loop through the "price" formfield, adding each item to a variable which holds the sum.

Hope that helps, and good luck.

- Patriarch
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
How to refresh a shopping cart window darksoap JavaScript 3 03-05-05 03:28 PM
shopping cart michelle Job Offers & Assistance 2 06-25-04 10:59 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
whats the best php free shopping cart script? dgames PHP 4 09-19-03 01:40 AM


All times are GMT -5. The time now is 06:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.