I'm trying to create a script that will calculate the tip a customer should pay, based on the number of customers and the amount of the bill. I also have to create an HTML document that has a form with two text boxes, one for number of customers and one foramount of bill(without tax and gratuity). 6 or more customers at a table is 18% gratuity, 5 or less at a table is 15% gratuity. I need to be able to print the gratuity amount to the screen.Also how much sales tax at 8.75% for bill? I need to display 4 amounts , the original amount, the sales tax amount, the gratuity amount and bill total including tax and gratuity. This is for a class that I'm in and I've been racking my brain on 2 or 3 problems. I was up most of last night trying to figure them out. I love this class and want to learn, but at some point I have to throw in the white flag. I appreciate your help! Just so you know, I'm doing this for a hobby as I'm almost 60 and retired from the Army in 2005. I really need a tutor. Thanks
This is what I have so far and it's not working in my PHP:
<?php
$customers = $_POST ['customers'];
$bill = $_POST ['bill'];
$tax = $_POST ['tax'];
while(customers >= 6) {
echo "$customers X $bill =", $bill .18, "<br>";
$customers++;
This is my HTML: I have 3 text boxes, Number of customers, Bill and NY Sales Tax and I also have a submit button that I named gratuity. Please help
burt.munn
0
Light Poster
Recommended Answers
Jump to PostIf you want to learn best way is on w3schools.com. You have examples and tutorials how to do form with post or get methods and so much more. I think that you will …
Jump to PostTry this
<form name="calcBill" id="calcBill" action="" method="post"> <label for="txtCustomersNo">Customers Number</label> <input type="text" name="txtCustomersNo" id="txtCustomersNo" value="<?php echo isset($_POST['txtCustomersNo']) ? $_POST['txtCustomersNo'] : "1"; ?>" /> <label for="txtAmount">Amount</label> <input type="text" name="txtAmount" id="txtAmount" value="<?php echo isset($_POST['txtAmount']) ? $_POST['txtAmount'] : "0"; ?>" /> <input type="submit" name="sbt" value="Calculate" /> </form> <?php if(isset($_POST['sbt'])) { …
Jump to PostYou'll want to change this:
$customers = $_POST ['customers']; $bill = $_POST ['bill']; $tax = $_POST ['tax'];
...to this:
$customers = $_POST['customers']; $bill = $_POST['bill']; $tax = $_POST['tax'];
...it's better in terms of syntax.
All 10 Replies
milil
24
Newbie Poster
Bachu
45
Newbie Poster
burt.munn
0
Light Poster
matrixdevuk
71
6t9.me Founder
burt.munn
0
Light Poster
burt.munn
0
Light Poster
Bachu
45
Newbie Poster
burt.munn
0
Light Poster
cigoL..:)
-1
Newbie Poster
burt.munn
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.