目前在我的网站上,我有一个表格,显示所有的学生数据,但我想有新的结果,通过选择学生的名字。通过这样做,我应该有一个表,显示他们的名字,姓氏,事件名称,事件长度,时间和排名只是为特定的学生和检查结果按钮不起作用。因为我是新来的,如果我能得到一些帮助就好了。非常感谢。
<form action = "result.php" method = "POST">
</form>
Select Student<br>
<select name="Stud">
<?php
//stores the query in the variable $all_names_query
$all_names_query ="Select * FROM Student ORDER BY FirstName ASC";
//Run the query and store the result in a variable called $all_names_results
$all_names_result=mysqli_query($dbcon, $all_names_query) ;
echo "<option value=>";
echo "Select Student";
echo "</option>";
//Fetching row of result as an associative array
while ($displayname=mysqli_fetch_assoc($all_names_result))
{
//Displaying the First Name of the Student in the drop down menu
echo "<option value='".$displayname['FirstName']."'>".$displayname['FirstName']."</option>";
}
?>
</select>
<p><input type = "submit" name = "submit" value="Check results"></p>
</form>
<table align="center" border="1">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Event</th>
<th>Event Length</th>
<th>Time</th>
<th>Rank</th>
</tr>
<?php
while($record = mysqli_fetch_assoc($Student_result)) {
echo "<tr>";
echo "<td>".$record['FirstName']."</td>";
echo "<td>".$record['LastName']."</td>";
echo "<td>".$record['EventName']."</td>";
echo "<td>".$record['EventLength']."m</td>";
echo "<td>".$record['Time']."s</td>";
echo "<td>".$record['Rank']."</td>";
echo "</tr>";
}
?>
</table>
PHP:
<?php
if (isset($_POST['Stud'])){
$Student = $_POST['Stud'];
}
$Student_query = "SELECT Student.StudentID, Student.FirstName, Student.LastName, Event.EventID, Event.EventName, Event.EventLength, Result.Time, Result.Rank
From Student, Event, Result
WHERE Student.StudentID = Result.StudentID
AND Result.EventID = Event.EventID
ORDER BY Student.StudentID, Student.FirstName";
$Student_result = mysqli_query ($dbcon, $Student_query);
$Student_rows = mysqli_num_rows($Student_result);
//if ($Student_rows > 0) {
//echo "There were ".$Student_rows." results!!";
//}
//else {
//echo "No results found!";
//}
?>
暂无答案!
目前还没有任何答案,快来回答吧!