2017-09-04 152 views
0

我正在此警告:警告:mysqli_fetch_assoc()预计参数1被mysqli_result,布尔在C中给出: XAMPP htdocs中 SMS上线 resultprocessing.php 47

mysqli_fetch_assoc()预计参数1至被mysqli_result,布尔 在C:\xampp\htdocs\sms\resultprocessing.php给出线47

这里是我的代码:

<?php 


$con = mysqli_connect("localhost", "root", "", "test"); 

if (isset($_POST['search'])) { 

    $searchquery = $_POST['search']; 
    $academic = $_POST['academic']; 
    $next = $_POST['termbegins']; 
    $term = $_POST['terms']; 
    $class = $_POST['class']; 

    $searchquery = preg_replace("#[^a-zA-Z0-9]#i", " ", $searchquery); 

    if ($term == "one") { 

     $sql_result = mysqli_query($con,"SELECT DISTINCT * FROM lowerprimaryone WHERE name = '$searchquery'"); 
    } 
    elseif ($term == "two"){ 

     $sql_result = mysqli_query($con, "SELECT DISTINCT * FROM lowerprimarytwo WHERE name = '$searchquery'"); 
    } 
    else{ 
     $sql_result = mysqli_query($con, "SELECT DISTINCT * FROM lowerprimarythree WHERE name = '$searchquery'"); 
    } 


     //$count = mysqli_num_rows($r); 

    if (!$sql_result || mysqli_num_rows($sql_result) == 0) { 

     echo "<table border='1'>" . "<thead> 
        <th>Thirty Percent (30%)</th> 
        <th>Seventy Percent (70%)</th> 
        <th>Hundred Percent (100%)</th> 
        <th>Remarks</th> 
       </thead>"; 

     echo "<strong style='margin-left: 27%'>NAME:</strong>" . "&nbsp" .$searchquery . "<strong style='margin-left: 250px'>". $term."</strong>"."<br>"; 

     echo "<p>" ."<strong style='margin-left: 27%'>YEAR:</strong>". "&nbsp" .$academic . "<strong style='margin-left: 330px'>DATE: ....</strong>" ."</p>" ; 

     echo "<p>". "<strong style='margin-left: 27%'>NEXT TERM BEGINS: </strong>" . "&nbsp". $next . "<strong style='margin-left: 15%'>Class/Form:</strong>" ."&nbsp". "$class ". "</p>"; 


     while ($row = mysqli_fetch_assoc($sql_result)) { 

      $name = $row['name']; 
      $surname = $row['surname']; 
      $country = $row['country']; 
      $language = $row['language']; 
      //$remark = $row['remarks']; 
      $id = $row['id']; 


      if (is_numeric($row['surname']) && is_numeric($row['country']) && is_numeric($row['language']) && is_numeric($row['language'])) { 

       if (isset($_POST)) 

        $result = (($surname + $country)/40) * 30; 

       $result2 = (($language)/(100.00)) * 70; 

       $final = $result + $result2; 

       if ($final > 79.00) { 

        $remark = "Excellent"; 

       } elseif ($final > 69.00 && $final < 80.00) { 

        $remark = "Very Good"; 
       } elseif ($final > 59.00 && $final < 70.00) { 

        $remark = "Good"; 
       } elseif ($final > 49.00 && $final < 60.00) { 

        $remark = "Pass"; 
       } elseif ($final > 39.1 && $final < 50.00) { 

        $remark = "Credit"; 
       } elseif ($final < 39) { 

        $remark = "Failed"; 
       } 


      } else { 

       echo "Enter numeric data for homework, test1, test2 and exams"; 
      } 





      echo "<tr><td>" . $result . "</td><td>" . $result2 . "</td><td>" . $final . "</td><td>" . $remark . "</td></tr>"; 
     } 

     echo "</table>"; 
    }else{ 

     print "Nothing Found"; 
    } 
} 

?> 
+0

我已经尝试了这么多的解决方案,但他们没有帮助 –

回答

0

已经创建了查询,但你还没有检索到的关联数组,

你的花括号后面添加此线26

$row=mysqli_fetch_assoc($sql_result); 

然后使用$ row变量在while循环通过数值来浏览循环。

相关问题