www.webdeveloper.com
Results 1 to 4 of 4

Thread: php math's issue

  1. #1
    Join Date
    Apr 2012
    Posts
    48

    php math's issue

    Hi

    I need some help with php math functions

    I have added a php order form to my website at the following

    http://www.irhwebsites.co.uk/web-design-order-form.php

    I have added a total deposit to pay now field

    Two issues, one is I want the total to be divided into 2 and then that figure displayed in the total deposit to pay now input field

    Second issue is after filling the details and clicking submit, I have made extra text saying total deposit to pay now, I want that to display the total price divided by 2 and then the paypal button to know that number divided into 2 and taken through to PayPal

    At the moment the paypal button is just taking the total price and going through to PayPal

    I can send over php files if that is possible through PM or by email if anyone wants to email me at ianhaney@irhwebsites.co.uk

    Thank you in advance

    Kind regards

    Ian

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    why don't you just show us you "math problems"? Not oodles of code, but the statement that are supposed to be doing what you want to do. Doing math in php is not rocket science.

  3. #3
    Join Date
    Apr 2012
    Posts
    48
    Hi Ginerjm

    Below is the math coding part I think

    PHP Code:
    $tbl->addRow();
                
    $tbl->addCell($name);
                
    $tbl->addCell('' number_format($price2) . $price_el'cur' );
                
    $tbl->addCell$qty_el'qty');
                
    $tbl->addCell$tot_el );
        }

    function 
    getOrderInfo() {
        global 
    $PRODUCTS;;
        
    $str ''$total 0;
        
        while ( list(
    $key$val) = each($_POST) ) {
            
    // Check for valid quantity entries
            
    if ( ( strpos($key'_qty') !== false ) && is_int((int)$val) && $val 0  ) { 
                
    $pt strrpos($key'_qty'); 
                
    $name_pt substr$key0$pt); // product abbr
                
                
    foreach($PRODUCTS as $product) {
                    list(
    $prod_abbr$prod_name$prod_price) = $product;
                    if (
    $prod_abbr == $name_pt) {
                        
    $sub_tot $val $prod_price;
                        
    // build string to display order info
                        
    $str .= "<p style='clear:both;'>$val $prod_name at " number_format($prod_price2) . 
                            
    /*' ' . number_format($sub_tot, 2) .*/ '</p>';
                        
    $total += $sub_tot;
                    }
                }
            }
        }
        if ( 
    $str === '' ) {
            
    $str '<p>You didn\'t order anything.</p>';
        } else {
            
    $str '<h2 class="ordertitle">Your Order:</h2>' $str '<br>' .'<p>Total: ' .  number_format($total2) . '<br><br>' 'Total Deposit to pay now: ' number_format($total2) . '</p>' getPayPalBtn($totaldeposit);
        }
        
        return 
    $str;

    Hope that helps

    Ian

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    Still don't see ANY math here. Is it buried in your class methods?

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



Recent Articles