我如何显示student.Student而不是student_id
<?php
for ($i = 0; $i < $chkcount; $i++) {
$id = $chk[$i];
$res = $MySQLiconn->query("SELECT Student.ID, student.Student, student.School,student.PR, Jumps.dis_ft_1, Jumps.dis_in_1, Jumps.dis_ft_2, Jumps.dis_in_2, Jumps.dis_ft_3, Jumps.dis_in_3, Jumps.dis_ft_4, Jumps.dis_in_4, Jumps.dis_ft_5, Jumps.dis_in_5, Jumps.dis_ft_6, Jumps.dis_in_6
FROM Student LEFT JOIN Jumps ON Student.ID = Jumps.student_id WHERE ID=" . $id);
while ($row = $res->fetch_array()) {
?>
<tr>
<td>
<input type="hidden" name="id[]" value="<?php echo $row['ID']; ?>"/>
Student ID: <input type="text" name="st[]" value="<?php echo $row['student_id']; ?>"
class="form-control"/>
Attempt 1 <input type="text" name="df1[]" value="<?php echo $row['dis_ft_1']; ?>"
class="form-control"/>
<input type="text" name="di1[]" value="<?php echo $row['dis_in_1']; ?>"
class="form-control"/>
Attempt 2 <input type="text" name="df2[]" value="<?php echo $row['dis_ft_2']; ?>"
class="form-control"/>
<input type="text" name="di2[]" value="<?php echo $row['dis_in_2']; ?>"
class="form-control"/>
Attemp 3 <input type="text" name="df3[]" value="<?php echo $row['dis_ft_3']; ?>"
class="form-control"/>
<input type="text" name="di3[]" value="<?php echo $row['dis_in_3']; ?>"
class="form-control"/>
Attempt 4 <input type="text" name="df4[]" value="<?php echo $row['dis_ft_4']; ?>"
class="form-control"/>
<input type="text" name="di4[]" value="<?php echo $row['dis_in_4']; ?>"
class="form-control"/>
Attempt 5 <input type="text" name="df5[]" value="<?php echo $row['dis_ft_5']; ?>"
class="form-control"/>
<input type="text" name="di5[]" value="<?php echo $row['dis_in_5']; ?>"
class="form-control"/>
Attempt 6 <input type="text" name="df6[]" value="<?php echo $row['dis_ft_6']; ?>"
class="form-control"/>
<input type="text" name="di6[]" value="<?php echo $row['dis_in_6']; ?>"
class="form-control"/>
</td>
</tr>
<?php
}
}
?>
不确定是否可以完成。但学生姓名会优于学生ID。 不会发布更多的文字,所以只需输入,它将发布。 我正在学习PHP。
答案 0 :(得分:0)
如果只有一个名为Student的字段,即Student.Student,则可以输出名称<?php echo $row['Student']; ?>
。
但是,如果存在名称冲突,您始终可以为该字段指定要访问的PHP的新名称。
SELECT Student.ID, Student.Student AS some_new_name FROM ....
<?php echo $row['some_new_name']; ?>