Results 1 to 8 of 8

Thread: PHP Caculator of fees and serives

  1. #1
    Join Date
    Oct 2004

    Thumbs up PHP Caculator of fees and serives

    Hello evreyone,
    I am EXTREMELY new to PHP, I am still trying to learn where all the resources are yet
    What I am trying to do is to make a caculator that will take and imputed number and caculate a percentage of it as a fee but I also want it to calulate a second fee percentage for if they were to sign up withthe service.
    Be something like this
    Amount of transaction: $1000.00
    Standard Fee: $50.00
    Gold Free: $30.00

    I was just wondering if anyone would know where i could find a torturial or something on how to caculate something like this... or a pre exsisting script i might base it off of.
    Thank you for any assistance

  2. #2
    Join Date
    Sep 2003
    Portsmouth, UK Occupation: Web Developer
    something like this

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Percentage Calculator</title>

    if(isset($_POST["cal"])) {
    $_POST["number"] == "" || !is_numeric($_POST["number"])) {
    "You Must Enter A Number</body></html>";
    } else {
    $number $_POST["number"];
    $stand = (5/100)*$number;
    $gold = (3/100)*$number;
    "Standard: ".$stand."<br />Gold: ".$gold."</body></html>";
    <form action="<?php echo $PHP_SELF?>" method="post">
    <p>Enter A Value <input type="text" name="number" size="4" /><br />
    <input type="submit" value="Calculate" name="cal" /></p>
    Richard Turner - A Virtual Insight

  3. #3
    Join Date
    Oct 2004
    Dang did you make that on the fly?
    that was a fast reply and i have to say i must bow down to your greatness LOL

    yeah its pretty close to what i am thinking... though why does it refreash the page? does it have to?

    And I guess since you here to ask
    if i wanted to add say an equation like 0-1000 = 3% 1000.01 to 5000 = 5% and so forth but still utilize the standard vrs gold vrs.
    I am thinking i would have to do an if statment to seperate the different variables and caculate from there... right? Or do i sound as dumb as i am feeling right now?

  4. #4
    Join Date
    Sep 2003
    Portsmouth, UK Occupation: Web Developer
    yes i did make that on the fly, just for you

    it refreshs the page? it shouldnt do maybe your browser doesnt support XHTML fully, thats my only guess do you have a link so i can try?

    im not sure what you mean about 0-1000 = 3% 1000.01 to 5000 = 5%

    do you mean instead of
    PHP Code:
    $number $_POST["number"];
    $stand = (5/100)*$number;
    $gold = (3/100)*$number;
    "Standard: ".$stand."<br />Gold: ".$gold."</body></html>"
    you use
    PHP Code:
    $number $_POST["number"];
    $number <= 1000) {
    $new = (3/100)*$number;
    } elseif(
    $number 1000 && $number 5000) {
    $new = (5/100)*$number;
    } else {
    $new = (7/100)*$number;
    "Value: ".$new."</body></html>"
    Richard Turner - A Virtual Insight

  5. #5
    Join Date
    Oct 2004
    I am really impressed withyou speed though i am guessing you probably think in PHP and not english right? heheh

    anyhow www.cafegears.com/totuinc/calculator.php is where i posted the codes you left me i did not change them

    when you hit the submit button the page resets to the awnser (in other words the part where you input the info changes to just the awnser) this is excepable i can certainly work with it but i was just cuious why it does. And i am useing IE most recent

    the idea here is sort of like an excrow service (though not what i am doing)
    i have a percentage fee basied on the amount of the trasaction

    soemthing like this
    $0 - 500 i get 5%
    500.01 - 1000 4.5%
    ect ect
    or if htey pay a monthly fee the percentages drop
    and i think thats what you got there though i have to play with and see
    Thank again for your help i do apreciate it... ALOT

  6. #6
    Join Date
    Sep 2003
    Portsmouth, UK Occupation: Web Developer
    Originally posted by shatter
    I am really impressed withyou speed though i am guessing you probably think in PHP and not english right? heheh
    hehe something like that

    ok sorry took so long replying was taking timeout watching a dvd, anyway the page doesnt refresh for me, you say you are using IE, may i slap you? try this for me http://www.mozilla.org/firefox/ and download http://www.chrispederick.com/work/firefox/webdeveloper/ this once in firefox, firefox is a browser and that is a brillaint webdev extension for it, and then tell me you still use IE ? , right....

    i think i now understand you meaning of 'refresh', PHP is a server side language therefore is server parsed, meaning the html form sends request to the server, php calculates the values and sends them back in HTML form. the reason why the form does not show on the second page is because of the exit() which tells php to basically end the HTML output here, try removing it and see what it does

    ok so the percentage is kinda like a fee ok try this keep all the same but change the PHP to

    PHP Code:
    if(isset($_POST["cal"])) {
    $_POST["number"] == "" || !is_numeric($_POST["number"])) {
    "You Must Enter A Number</body></html>";
    } else {
    $number $_POST["number"];
    $number <= 500) {
    $new = (5/100)*$number;
    } elseif(
    $number 500 && $number <= 1000) {
    $new = (4.5/100)*$number;
    } elseif(
    $number 1000 && $number <= 1500) {
    $new = (4/100)*$number;
    //you could continue here by adding more elseif() continuing the above pattern, but keep the else this is for anything that doesnt fit the above if() or elseif()s
    } else {
    $new = (3.5/100)*$number;
    "Transfer After Fees: $".number_format($new2'.''')."</body></html>";
    Richard Turner - A Virtual Insight

  7. #7
    Join Date
    Oct 2004
    Looks great so far
    and when do you want to do free lance work for me

    so far it looks great... except i think we lost the gold and standard part in this or maybe i am missing something... ok i am missing something LOL
    I am tihnking i should just add the
    $stand = (5/100)*$number;
    $gold = (3/100)*$number;
    to the if statments... i am going ot try it out just after dinner but figured i should ask so you have time to post when i find out i am doing it wrong and start pulling my hair out LOL

    Thanks again

  8. #8
    Join Date
    Oct 2004
    OOh and i am codeing to my audiance which is 100% IE browsers

    Of course right now the browser is only HTML 1.0 enabled but next month its supposed to go to HTML 4.0... if that even remotely gives you an idea of my nightmare LOL

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.36888 seconds
  • Memory Usage 2,936KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates