Jump to content


Photo

Leaning how to add.


  • Please log in to reply
1 reply to this topic

#1 ylonek

ylonek
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 April 2005 - 05:04 PM

I am trying to setup a checkout using a drop down list. I would like to give a price for each item and have that added to a checkout total. I am very new at this.

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 01 April 2005 - 06:07 PM

I am trying to setup a checkout using a drop down list. I would like to give a price for each item and have that added to a checkout total. I am very new at this.

View Post



if you are looping through your results to list the items and prices, just add each price to the total as you list it:
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
[span style=\"color:#0000BB\"]<?php
$total [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"];
[/span][span style=\"color:#0000BB\"]$result [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT * FROM shopping_cart\"[/span][span style=\"color:#007700\"]);
while ([/span][span style=\"color:#0000BB\"]$row [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$result[/span][span style=\"color:#007700\"])) {
    echo [/span][span style=\"color:#DD0000\"]\"$row[item] - $row[price]<br />\n\"[/span][span style=\"color:#007700\"];
    [/span][span style=\"color:#0000BB\"]$total [/span][span style=\"color:#007700\"]+= [/span][span style=\"color:#0000BB\"]$row[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'price\'[/span][span style=\"color:#007700\"]];
}
echo [/span][span style=\"color:#0000BB\"]$total[/span][span style=\"color:#007700\"];
[/span][span style=\"color:#0000BB\"]?>
[/span]
[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users