我创建了一个网站,用于帮助教授ECDL。在一个页面上,我有一个教师概述,它使用php和SQLi来取得学生的进度,并根据主题将其放入表中。Overview Page
我有3个主题,我使用标签进行导航,为了避免冗余,我已经把代码填充到一个php文件中,并在html中使用包含vaiables。第一个主题工作正常,但第二个和第三个主题是课程文本和学生名称被填充,但进度返回false,警告:mysqli_fetch_row()期望参数1为mysqli_result,给定布尔值。
我试图取消设定变量,免费结果等无济于事。用户的第二个主题数据库表当前是空的,但第三个不是。 pres DB table如果我不使用inlcude文件,它们将有效,但我希望将来保持整洁/易于编辑。
Overview.php
<ul class="tab">
<li><a href="#" class="tablinks" onclick="openLesson(event, '1')">Word Processing</a></li>
<li><a href="#" class="tablinks" onclick="openLesson(event, '2')">Speedsheets</a></li>
<li><a href="#" class="tablinks" onclick="openLesson(event, '3')">Presentation</a></li>
</ul>
<div id="1" class="tabcontent" style="padding-top:0; max-height:2000px">
<div>
<?php
$mod = "word";
$sec = "wp";
include("../../SCRIPT/PHP/progOver.php");
?>
</div>
</div>
<div id="2" class="tabcontent" style="padding-top:0; max-height:2000px">
<div>
<?php
$mod = "excel";
$sec = "ss";
include("../../SCRIPT/PHP/progOver.php");
?>
</div>
</div>
<div id="3" class="tabcontent" style="padding-top:0; max-height:2000px">
<div>
<?php
$mod = "pres";
$sec = "pp";
include("../../SCRIPT/PHP/progOver.php");
?>
</div>
</div>
progOver.php
$sql_text = mysqli_query($con,"SELECT * FROM ".$sec."_text ORDER BY id ASC");
$sql_users ="SELECT username, f_name, s_name FROM user WHERE class ='".$class."' ORDER BY s_name ASC";
$x = 1;
$time = "";
if($result = mysqli_query($con, $sql_users)){
echo"<div class ='xyz'><table class='progress'>";
echo"<thead >\n<tr>\n";
echo"<th class='headcol' style='width:100px;height:250px;'></th>\n";
while($row = mysqli_fetch_array($sql_text)){
echo"<th class ='vert' ><div class='vert'>".$row["name"]."</div></th>\n";
}
//print_r($result);
echo "</tr>\n</thead>\n<tbody>\n";
while($row_user = mysqli_fetch_row($result)){
echo "<tr>\n";
$sql_rag = "SELECT ".$mod.".".$sec."_lesson, ".$mod.".rag, ".$sec."_text.id, ".$mod.".comp_on FROM ".$mod." INNER JOIN ".$sec."_text ON ".$mod.".".$sec."_lesson = ".$sec."_text.".$sec."_lesson WHERE username = '".$row_user[0]."' ORDER BY ".$mod.".username, ".$sec."_text.id ASC";
$result_rag = mysqli_query($con, $sql_rag);
echo '<th class="headcol">'.$row_user[1].' '.$row_user[2].'</th>';
//print_r($result_rag);
if($result_rag){
while($row_rag = mysqli_fetch_row($result_rag)){ //Error here
$time = $row_rag[3];
if($x == $row_rag[2]){
if($row_rag[1] == "Green"){
echo "<td class='long'style='background-color:green;' alt=".$time." title=".$time."></td>\n";
$x++;
}else if($row_rag[1] == "Red"){
echo "<td class='long' style='background-color:red;' alt=".$time." title=".$time."></td>\n";
$x++;
}if($row_rag[1] == "Amber"){
echo "<td class='long' style='background-color:orange;' alt=".$time." title=".$time."></td>\n";
$x++;
}
}else{
echo"<td class='long'>X</td>\n";
$x = $x+2;
}
}
}
echo "</tr>\n";
$x=1;
}
echo"</table>\n</div>\n";
mysqli_free_result($result);
}