PHP回显INF而不是成绩的结果

PHP回显INF而不是成绩的结果,php,Php,我正在开发一个成绩系统,我添加了成绩功能来显示成绩,但我得到的是INF而不是成绩。我得到的结果见图片附件 下面是完整的代码 <?php session_start(); error_reporting(0); include('includes/config.php'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">

我正在开发一个成绩系统,我添加了成绩功能来显示成绩,但我得到的是INF而不是成绩。我得到的结果见图片附件

下面是完整的代码

<?php
session_start();
error_reporting(0);
include('includes/config.php');
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Result System</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" media="screen" >
        <link rel="stylesheet" href="css/font-awesome.min.css" media="screen" >
        <link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen" >
        <link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen" >
        <link rel="stylesheet" href="css/prism/prism.css" media="screen" >
        <link rel="stylesheet" href="css/main.css" media="screen" >
        <script src="js/modernizr/modernizr.min.js"></script>
    </head>
    <style>
        body {
            background: url(images/logo.png);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }
    </style>
    <body>
        <div class="main-wrapper">
            <div class="content-wrapper">
                <div class="content-container">


                    <!-- /.left-sidebar -->

                    <div class="main-page">
                        <div class="container-fluid">
                            <div class="row page-title-div">
                                <div class="col-md-12">
                                    <h2 class="login100-form-title" align="center"><img src="images/nations.png" alt="" height="auto" width="700px"></h2>
                                </div>
                            </div>
                            <!-- /.row -->

                            <!-- /.row -->
                        </div>
                        <!-- /.container-fluid -->

                        <section class="section">
                            <div class="container-fluid">

                                <div class="row">



                                    <div class="col-md-8 col-md-offset-2">
                                        <div class="panel">
                                            <div class="panel-heading">
                                                <div class="panel-title">
<?php
// code Student Data
$rollid=$_POST['rollid'];
$classid=$_POST['class'];
$_SESSION['rollid']=$rollid;
$_SESSION['classid']=$classid;
$query = "SELECT   tblstudents.StudentName,tblstudents.RollId,tblstudents.RegDate,tblstudents.StudentId,tblstudents.Status,tblclasses.ClassName,tblclasses.Section from tblstudents join tblclasses on tblclasses.id=tblstudents.ClassId where tblstudents.RollId=:rollid and tblstudents.ClassId=:classid ";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':rollid',$rollid,PDO::PARAM_STR);
$stmt->bindParam(':classid',$classid,PDO::PARAM_STR);
$stmt->execute();
$resultss=$stmt->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($stmt->rowCount() > 0)
{
foreach($resultss as $row)
{   ?>
<p><b>Student Name :</b> <?php echo htmlentities($row->StudentName);?></p>
<p><b>Student Roll Id :</b> <?php echo htmlentities($row->RollId);?>
<p><b>Student Class:</b> <?php echo htmlentities($row->ClassName);?>(<?php echo htmlentities($row->Section);?>)
<?php }

    ?>
                                            </div>
                                            <div class="panel-body p-20">







                                                <table class="table table-hover table-bordered">
                                                <thead>
                                                        <tr>
                                                            <th>#</th>
                                                            <th>Subject</th>    
                                                            <th>Marks</th>
                                                        </tr>
                                               </thead>




                                                    <tbody>
<?php                                              
// Code for result

 $query ="select t.StudentName,t.RollId,t.ClassId,t.marks,SubjectId,tblsubjects.SubjectName from (select sts.StudentName,sts.RollId,sts.ClassId,tr.marks,SubjectId from tblstudents as sts join  tblresult as tr on tr.StudentId=sts.StudentId) as t join tblsubjects on tblsubjects.id=t.SubjectId where (t.RollId=:rollid and t.ClassId=:classid)";
$query= $dbh -> prepare($query);
$query->bindParam(':rollid',$rollid,PDO::PARAM_STR);
$query->bindParam(':classid',$classid,PDO::PARAM_STR);
$query-> execute();  
$results = $query -> fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($countrow=$query->rowCount()>0)
{ 

foreach($results as $result){

    ?>

                                                        <tr>
                                                <th scope="row"><?php echo htmlentities($cnt);?></th>
                                                            <td><?php echo htmlentities($result->SubjectName);?></td>
                                                            <td><?php echo htmlentities($totalmarks=$result->marks);?></td>
                                                        </tr>
<?php 
$totlcount+=$totalmarks;
$cnt++;}
?>

<?php
$grade = $totlcount*(100)/$outof;
    if ($grade >= 70)
    {
        $class = "<span> A(Excellent)  </span>";
    }
    else if (($grade < 70) && ($grade >= 60))
    {
        $class = "<span> B(V.Good) </span>";
    }
    else if (($grade < 69) && ($grade >=50))
    {
        $class = "<span> C(Good)</span>";
    }
    else if (($grade < 49) && ($grade >=45))
    {
        $class = "<span> D(Average)  </span>";
    }
    else if (($grade < 44) && ($grade >= 40))
    {
        $class = "<span> E(Below Average)s  </span>";
    }
    else
    {
        $class = "<span> F(Failed) </span>";
    }

?>
<tr>
                                                <th scope="row" colspan="2">Total Marks</th>
<td><b><?php echo htmlentities($totlcount); ?></b> out of <b><?php echo htmlentities($outof=($cnt-1)*100); ?></b></td>
                                                        </tr>
<tr>
                                                <th scope="row" colspan="2">Percentage</th>           
                                                            <td><b><?php echo  htmlentities($totlcount*(100)/$outof); ?> %</b></td>
                                                             </tr>

                                                             <tr>
                                                <th scope="row" colspan="2">Grade</th>           
                                                            <td><b><?php echo  htmlentities($grade); ?> </b></td>
                                                             </tr>
<tr>
                                                <th scope="row" colspan="2">Download Result</th>           
                                                            <td><b><a href="download-result.php">Download </a> </b></td>
                                                             </tr>

 <?php } else { ?>     
<div class="alert alert-warning left-icon-alert" role="alert">
                                            <strong>Notice!</strong> Your result not declare yet
 <?php }
?>
                                        </div>
 <?php 
 } else
 {?>

<div class="alert alert-danger left-icon-alert" role="alert">
<strong>Oh snap!</strong>
<?php
echo htmlentities("Invalid Reg Number");
 }
?>
                                        </div>



                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                        <!-- /.panel -->
                                    </div>
                                    <!-- /.col-md-6 -->

                                    <div class="form-group">

                                                            <div class="col-sm-6">
                                                               <b><a href="index.php" style="color: black;">Back to Home</a></b>
                                                            </div>
                                                        </div>

                                </div>
                                <!-- /.row -->

                            </div>
                            <!-- /.container-fluid -->
                        </section>
                        <!-- /.section -->

                    </div>
                    <!-- /.main-page -->


                </div>
                <!-- /.content-container -->
            </div>
            <!-- /.content-wrapper -->

        </div>
        <!-- /.main-wrapper -->

        <script src="js/jquery/jquery-2.2.4.min.js"></script>
        <script src="js/bootstrap/bootstrap.min.js"></script>
        <script src="js/pace/pace.min.js"></script>
        <script src="js/lobipanel/lobipanel.min.js"></script>
        <script src="js/iscroll/iscroll.js"></script>

        <script src="js/prism/prism.js"></script>
        <script src="js/main.js"></script>
        <script>
            $(function($) {

            });
        </script>

    </body>
</html>

结果系统
身体{
背景:url(images/logo.png);
背景尺寸:封面;
背景位置:中心;
背景重复:无重复;
}
学生姓名:

学生名册编号: 学生班级:() # 主题 标志 总分 从…里面 百分比 % 等级 下载结果 注意您的结果尚未声明 哦,快 $(函数($){ });
这是我为这个年级写的

<?php
$grade = $totlcount*(100)/$outof;
    if ($grade >= 70)
    {
        $class = "<span> A(Excellent)  </span>";
    }
    else if (($grade < 70) && ($grade >= 60))
    {
        $class = "<span> B(V.Good) </span>";
    }
    else if (($grade < 69) && ($grade >=50))
    {
        $class = "<span> C(Good)</span>";
    }
    else if (($grade < 49) && ($grade >=45))
    {
        $class = "<span> D(Average)  </span>";
    }
    else if (($grade < 44) && ($grade >= 40))
    {
        $class = "<span> E(Below Average)s  </span>";
    }
    else
    {
        $class = "<span> F(Failed) </span>";
    }

?>

我用它输出

<th scope="row" colspan="2">Grade</th>           
                                                        <td><b><?php echo  htmlentities($grade); ?> </b></td>
等级

$outof
在您使用它计算
$grade
之后才被定义。你得走了

$outof = ($cnt-1) * 100
在这一行之前:

$grade = $totlcount*(100)/$outof;

在您使用它计算
$grade
之前,不会定义
$outof
。你得走了

$outof = ($cnt-1) * 100
在这一行之前:

$grade = $totlcount*(100)/$outof;

除了不起作用的分数,一切都很好。除了不起作用的分数,一切都很好。这回答了你的问题吗?如果没有,你能提供更多的信息来帮助回答这个问题吗?否则,请考虑标记接受的答案(在上/下投票箭头下的复选标记)。看,这回答了你的问题吗?如果没有,你能提供更多的信息来帮助回答这个问题吗?否则,请考虑标记接受的答案(在上/下投票箭头下的复选标记)。看到和