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 Thank you in advance Kind regards Ian
Sounds pretty straightforward... how about you post the relevant bits of code that are causing trouble and wrap them in [ php] bbcode.
Hi sarahk Thank you for the reply I have posted below the relevant coding If need be, I can zip the file and attach it // total row $tbl->addRow(); $tbl->addCell( 'Total: ', 'total', 'data', array('colspan'=>3) ); $tbl->addCell( $frm->addInput('text', 'total', 0, array('readonly'=>true, 'size'=>8, 'class'=>'cur') ) ); // total deposit row $tbl->addRow(); $tbl->addCell( 'Total deposit to pay now: ', 'totaldeposit', 'data', array('colspan'=>3) ); $tbl->addCell( $frm->addInput('text', 'totaldeposit', 0, array('readonly'=>true, 'size'=>8, 'class'=>'cur') ) ); PHP: Below is the paypal button code <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin-top: 3%;"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="$paypal_email" /> <input type="hidden" name="amount" value="$totaldeposit" /> - see where I added deposit to the word total, it was just total before <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="item_name" value="$desc" /> <input type="hidden" name="custom" value="$custom" /> <input type="hidden" name="return" value="$return_url" /> <input type="hidden" name="cancel_return" value="$cancel_url" /> <input type="image" name="submit "border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online" /> </form> Code (markup): Bit more PHP below if ( $str === '' ) { $str = '<p>You didn\'t order anything.</p>'; } else { $str = '<h2 class="ordertitle">Your Order:</h2>' . $str . '<br>' .'<p>Total: £' . number_format($total, 2) . '<br><br>' . 'Total Deposit to pay now: £' . number_format($total, 2) . '</p>' . getPayPalBtn($totaldeposit); } return $str; } PHP: Hope that all helps Ian
Can you not access that $total variable and just do this before you call the button? $totaldeposit = $total/2; PHP: