1
I need a PHP code from a calculator, which adds 4 notes and divides by 4 and if the final average is greater than or equal to 6 that it shows approved, if not disapproved. SCRR
<?php
$nt1 = $_GET[$nt1];
$nt2 = $_GET[$nt2];
$nt3 = $_GET[$nt3];
$nt4 = $_GET[$nt4];
$mf = ( $nt1 + $nt2 + $nt3 + $nt4)/4;
echo " $nt1, $nt2, $nt3, $nt4, $mf ";
if ( $mf >= 6 ) {
echo "aprovado" ;
}
else{
echo "Reprovado";
}
?>
HTML code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> calculadora </title>
</head>
<body>
<form action="calculadora.php" method = "get">
<table border="1" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td>Primeiro bimestre</td>
<td><input name="$nt1" type="text" /></td>
</tr>
<tr>
<td>Segundo bimestre</td>
<td><input name="$nt2" type="text" /></td>
</tr>
<tr>
<td>terceiro bimestre</td>
<td><input name="$nt3" type="text" /></td>
</tr><tr>
<td>quarto bimestre</td>
<td><input name="$nt4" type="text" /></td>
</tr>
<tr>
<td></td>
<td><input name="bt_validar" type="submit" value="Calcular" /></td>
</tr>
</tbody>
</table>
</body>
</html>
You could post the HTML code of your form here?
– Allan Andrade
can yes, more aq in the comments does not fit
– Cristina
I’ll edit the question and post there may be??
– Cristina
Elaborate on your question Cristina. Stackoverflow doesn’t work like this: "I want code X for yesterday because I have a deadline." Which part of the code did you not understand? What is your question exactly? Where is the corresponding HTML code?
– Ericson Willians
can’t you do the calculation? I think it’s best to change the
name
s of inputs, take out that cipher.– rray
It is pq in the code in PHP, it should show the result of the sums qnd do the division and if it was greater or equal to 6 it was to give approved and if it was smaller it was to fail, only goes to the condition of Else, regardless of the value that gives. and I don’t find the error
– Cristina
HTML code put in question
– Cristina
rray, input numbers are the variables I used in PHP
– Cristina
If it is falling only on Else its variables must be as zero or null look:
$nt1 = $_GET[$nt1];
so you say for php, want the Intel$_GET
only he doesn’t exist ...– rray
More want the user to give the value of the variable understand? what can I put in place? Can help me?
– Cristina
In all variable php starts with
$
just take it out of the name of inputs and$nt1 = $_GET[$nt1];
, let alone$nt1 = $_GET['nt1'];
– rray
Got it, it was missing simple quotes in the variable. Obg rray
– Cristina