•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,024 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1627 | Replies: 1
![]() |
•
•
Join Date: Jan 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Morning all,
I don't know how to solve this problem Here it is:
In form html
Result: qty value: 1
When I change qty to 0, 1, 2, 3, 4, etc.. gross value stay ar 20.45.
What is wrong in my code ?
Regards to all.
I don't know how to solve this problem Here it is:
•
•
•
•
$price_unit = "20.45"
$qty = 'qty';
$net = 'net';
$net = $qty * $price_unit ;
as: 0<$qty<10 to parse in a textbox.
I do that :
if
($qty =0)
{
$net =0;
}
elseif
($qty =1) {
$net = $price_unit * 1;
}
elseif
($qty = 2) {
$net = $price_unit * 2;
}
....
else{echo "Message...."}
•
•
•
•
.....
<input type = "text" name = "qty" value = "<?php echo $qty ?>" size = "6">
<input type = "text" name = "gross" value = "$qty * $price_unit" size = "6">
Result: qty value: 1
When I change qty to 0, 1, 2, 3, 4, etc.. gross value stay ar 20.45.
What is wrong in my code ?
Regards to all.
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 5
Your code:
$price_unit = "20.45" // this is not numeric
$qty = 'qty'; // this mean the value in $qty is a word
$net = 'net'; // this mean the value in $net is a word
They should look like:
$price_unit = 20.45; // this is now numeric value
$qty = $_POST['qty']; // assume you use post in the form
$net = $proce_unit*$qty;
To set the condition, use if...else function.
$price_unit = "20.45" // this is not numeric
$qty = 'qty'; // this mean the value in $qty is a word
$net = 'net'; // this mean the value in $net is a word
They should look like:
$price_unit = 20.45; // this is now numeric value
$qty = $_POST['qty']; // assume you use post in the form
$net = $proce_unit*$qty;
To set the condition, use if...else function.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Parsing html form. (PHP)
- parsing error (XML file-java-schema) (Java)
- Parsing an atom feed (PHP)
- File parsing in 'C' (C)
Other Threads in the PHP Forum
- Previous Thread: embedding java script in php
- Next Thread: Seeting up and calling variables stored in sessions


Linear Mode