Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<form action="" method="post">
<input name="percent" type="text" size="6" maxlength="10"> percent of 100
<br><br>
<input name="submit" type="submit" value="Calculate">
<input name="total" type="hidden" value="100">
</form>
<?php
$submit = $_POST['submit'];
$percent = $_POST['percent'];
$total = $_POST['total'];
// Simple
if ($submit == true) {
$ans = $percent / $total;
}
$ans = number_format($ans, 2, ',', ' ');
echo "<p>The answer is $ans</p>";
?>
<?php
// Simple
if (isset($_POST['submit']) {
$percent = $_POST['percent'];
$total = $_POST['total'];
$ans = $percent / $total;
$ans = number_format($ans, 2, ',', ' ');
echo "<p>The answer is $ans</p>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title></title>
</head>
<form action="" method="post">
<input name="percent" type="text" size="6" maxlength="10"> percent of 100
<br><br>
<input name="submit" type="submit" value="Calculate">
<input name="total" type="hidden" value="100">
</form>
<?php
$submit = $_POST['submit'];
$percent = $_POST['percent'];
$total = $_POST['total'];
// Simple
if ($submit == true) {
$ans = $percent / $total;
}
$ans = number_format($ans, 2, ',', ' ');
echo "<p>The answer is $ans</p>";
?>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title></title>
</head>
<form action="" method="post">
<input name="percent" type="text" size="6" maxlength="10"> percent of 100
<br><br>
<input name="submit" type="submit" value="Calculate">
<input name="total" type="hidden" value="100">
</form>
<?php
$submit = $_POST['submit'];
$percent = $_POST['percent'];
$total = $_POST['total'];
// Simple
if ($submit == true) {
$ans = $percent / $total;
}
$ans = number_format($ans, 2, ',', ' ');
$result = $total - $ans;
echo "<p>The answer is $result</p>";
?>
</body>
</html>
[code]
it keeps giveing answer as 100 what ever figure i type in
Thanks for the help
<?php
if (isset ($_POST['foo'])
{
//process the value in the form-field "foo"
print '
<html>
<body>
You submitted the value: ' . $_POST['foo'] . '
</body>
</html>';
}
else
{
//produce the HTML form that includes a field named "foo"
print '
<html>
<body>
<form method="post" action="' . $_SERVER['PHP_SELF'] . '">
<input type="text" name="foo"><br>
<input type="submit">
</form>
</body>
</html>';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>do a percent</title>
</head>
<body>
<form method="post" action="percent2.php" />
<input name="percent" type="text" size="6" maxlength="10" /> percent of 100
<br><br>
<input name="total" type="hidden" value="100" />
<input name="submitme" type="submit" value="Calculate" />
</form>
</body>
</html>
<?php
if(isset($_POST['percent']))
{
$percent = $_POST['percent'];
$total = $_POST['total'];
// Simple
//this will give 90
$ans = ($total*$percent) ;
//$ans = number_format($ans, 2, ',', ' ');
echo '<p>The answer is '.$ans. '</p>';
}
echo '<a href="percent1.php">go back</a>';
?>