在 mysqli 列中显示选定值
Display selected values in mysqli columns
我只想在 Department 列中仅输出 Agric Department。我该怎么做。提前致谢。这是我的代码。
<thead>
<tr>
<th>SL</th>
<th>Student Name</th>
<th>Department</th>
<th>Age</th>
<th>Photo</th>
</tr>
</thead>
<tbody>
<?php
$query=mysqli_query($db_con,'SELECT *
FROM `student_info`
ORDER BY `student_info`.`datetime` DESC;');
$i=1;
while ($result = mysqli_fetch_array($query)) { ?>
<tr>
<?php
echo '<td>'.$i.'</td>
<td>'.ucwords($result['name']).'</td>
<td>'.ucwords($result['department']).'</td>
<td>'.ucwords($result['age']).'</td>
<td><img class="rounded-circle avatar-xl" src="../../images/'.$result['photo'].'" ></td>';?>
</tr>
<?php $i++;} ?>
</tbody>
</table>
我想实现的是只显示农业系的学生
更改您的查询
SELECT * FROM `student_info` ORDER BY `student_info`.`datetime` DESC
至
SELECT * FROM `student_info` where department = 'Agric' ORDER BY `student_info`.`datetime` DESC
我只想在 Department 列中仅输出 Agric Department。我该怎么做。提前致谢。这是我的代码。
<thead>
<tr>
<th>SL</th>
<th>Student Name</th>
<th>Department</th>
<th>Age</th>
<th>Photo</th>
</tr>
</thead>
<tbody>
<?php
$query=mysqli_query($db_con,'SELECT *
FROM `student_info`
ORDER BY `student_info`.`datetime` DESC;');
$i=1;
while ($result = mysqli_fetch_array($query)) { ?>
<tr>
<?php
echo '<td>'.$i.'</td>
<td>'.ucwords($result['name']).'</td>
<td>'.ucwords($result['department']).'</td>
<td>'.ucwords($result['age']).'</td>
<td><img class="rounded-circle avatar-xl" src="../../images/'.$result['photo'].'" ></td>';?>
</tr>
<?php $i++;} ?>
</tbody>
</table>
我想实现的是只显示农业系的学生
更改您的查询
SELECT * FROM `student_info` ORDER BY `student_info`.`datetime` DESC
至
SELECT * FROM `student_info` where department = 'Agric' ORDER BY `student_info`.`datetime` DESC