我得到一个错误:
FATAL ERROR: Function name Must be a string in C:\xampp\localhost\student\viewgrades.php on line 78
。
如果成绩超过75,我想制作一份if语句,那么它应该echo 'passed'
,但如果计算的成绩低于75,我应该'echo failed'
。
对于代码结构很抱歉,我对PHP的了解仍然有限
<?php
$resultp = mysql_query("SELECT * FROM prelcent");
$row = mysql_fetch_array($resultp);
$prelcent=$row['percentage'];
$resultpp = mysql_query("SELECT * FROM midcent");
$row = mysql_fetch_array($resultpp);
$midcent=$row['percentage'];
$resultppp = mysql_query("SELECT * FROM precent");
$row = mysql_fetch_array($resultppp);
$precent=$row['percentage'];
$resultpppp = mysql_query("SELECT * FROM fincent");
$row = mysql_fetch_array($resultpppp);
$fincent=$row['percentage'];
$remark = (($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent));
if ($remark() >75) <<<<<Line 78 {
$rem1 = "echo 'passed!';";
} else {
if ($remark()<75) {
$rem1 = "echo 'failed';";
}
}
echo "<td>". $rem1 ."</td>"
?>
答案 0 :(得分:4)
你可以试试吗
if ($remark >75)
因为$remark
不是function
。它的变量是
($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent)
答案 1 :(得分:2)
$remark
变量,而不是function
,所以应该是,$rem1 = "passed!";
代替$rem1 = "echo 'passed!';";
if ($remark > 75){
$rem1 = "passed!";
}
而不是
if ($remark() > 75){
$rem1 = "echo 'passed!';";
}
您的代码应该是,
$remark = (($pre*$prelcent)+($mid*$midcent)+($prf*$precent)+($fin*$fincent));
if ($remark > 75) {
$rem1 = "passed!";
} else {
if ($remark < 75) {
$rem1 = "failed";
}
}
echo "<td>". $rem1 ."</td>";
答案 2 :(得分:0)
$ rem1 =“echo'传递!';”;使它看起来像一个功能。为了使它看起来像变量,它应该是$ rem1 =“传递!”;