我想如果工作人员去申请页面查看学生的申请表。它只会查看apply_status ='PENDING'的状态。之前已批准的状态将不会在页面中查看。 .................................................. ..............................
如果只有apply_status ='PENDING'只能在页面中查看,那么这是我的代码。 ...我添加了if else语句......但是没有用。如果有几个apply_status =已批准。它不会显示待处理的。但是如果没有apply_status = aprroved。它将查看所有应用程序。
<?php
include("connection.php");
$sql="SELECT * FROM application";
$record = mysqli_query($con, $sql) or die ("error".mysqli_error($con));
$apply = mysqli_fetch_assoc($record);
$status1 = $apply["apply_status"];
if ($status1 == "APPROVED") {
echo "<br>";
echo "No application from student yet.<br>";
echo "<br>";
}
else {
echo "<table border='1'><tr>
<td><strong>Student ID</strong></td>
<td><strong>Student Name</strong></td>
<td><strong>Kelompok</strong></td>
<td><strong>Block</strong></td>
<td><strong>Level</strong></td>
<td><strong>House</strong></td>
<td><strong>Status</strong></td>
</tr>";
$i=0;
while ($ww=mysqli_fetch_array($query))
{
if ($i%2==0)
$class="evenRow";
else
$class="oddRow";
$id=$ww[0];
$studentid=$ww[1];
$name=$ww[2];
$kelompok=$ww[8];
$block=$ww[9];
$level=$ww[10];
$house=$ww[11];
$status=$ww[14];
echo '<tr>
<input type="hidden" name="applyid['.$i.']" value="'.$id.'"/>
<td>'.$studentid.'</td>
<td>'.$name.'</td>
<td>'.$kelompok.'</td>
<td>'.$block.'</a></td>
<td>'.$level.'</td>
<td>'.$house.'</td>
<td>
<input type="checkbox" name="status['.$i.']" value="approved" checked> APPROVED <br>
</td>
</tr>';
$i++;
}
echo '</table>';
}
我认为错误发生在if else声明中,但我不知道如何区分apply_status = approved和apply_status = pending。
答案 0 :(得分:0)
试试这个, 记住,
$status1 = $apply["apply_status"];
应该是循环的一部分,可能有行。
<?php
include("connection.php");
$sql="SELECT * FROM application";
$record = mysqli_query($con, $sql) or die ("error".mysqli_error($con));
$i=0;
$number_of_rows = mysql_num_rows($record);
if ($number_of_rows == 0) {
echo "<br>";
echo "No application from student yet.<br>";
echo "<br>";
} else {
while ($ww=mysqli_fetch_array($record))
{
echo "<table border='1'><tr>
<td><strong>Student ID</strong></td>
<td><strong>Student Name</strong></td>
<td><strong>Kelompok</strong></td>
<td><strong>Block</strong></td>
<td><strong>Level</strong></td>
<td><strong>House</strong></td>
<td><strong>Status</strong></td>
</tr>";
if ($i%2==0)
$class="evenRow";
else
$class="oddRow";
$id=$ww[0];
$studentid=$ww[1];
$name=$ww[2];
$kelompok=$ww[8];
$block=$ww[9];
$level=$ww[10];
$house=$ww[11];
$status=$ww[14];
echo '<tr>
<input type="hidden" name="applyid['.$i.']" value="'.$id.'"/>
<td>'.$studentid.'</td>
<td>'.$name.'</td>
<td>'.$kelompok.'</td>
<td>'.$block.'</a></td>
<td>'.$level.'</td>
<td>'.$house.'</td>
<td>
<input type="checkbox" name="status['.$i.']" value="approved" checked> APPROVED <br>
</td>
</tr>';
$i++;
}
echo '</table>';
}
答案 1 :(得分:0)
我的代码中找不到“员工”状况,
include("connection.php");
$sql="SELECT * FROM application";
if($staff){
$sql = $sql. " WHERE apply_status = 'PENDING'";
}else{
$sql = $sql. " WHERE apply_status = 'APPROVED'";
}