我在 php html 中有一个小表单,有五个字段。名字、姓氏、班级、年龄、分数。我想通过单击记录登录页面上的添加按钮来获取前三个字段(名字、姓氏、班级)的值。 (登陆页面有这些字段 FirstName、Lastname、class、Add 按钮)
表格代码
<form method=post, action="">
Firstname <Input type=text name=fname, id=fname, value="">
Lasttname <Input type=text name=lastname, id=lastname, value="">
Class <Input type=text name=class, id=class, value="">
Age <Input type=text name=Age, id=Age, value="">
Marks <Input type=text name=marks, id=marks, value="">
</form>
登陆页面代码
// Attempt select query execution
$sql = "SELECT * FROM mis1";
if ($result = mysqli_query($link, $sql)) {
if (mysqli_num_rows($result) > 0) {
echo '<table class="styled-table">';
echo "<thead>";
echo "<tr>";
echo "<th>FirstName</th>";
echo "<th>LastName</th>";
echo "<th>Class</th>";
echo "<th>Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['fname'].
"</td>";
echo "<td>".$row['lastname'].
"</td>";
echo "<td>".$row['class'].
"</td>";
echo "<td>";
echo '<a href="ua1.php?id='.$row['id'].
'" class="mr-3" title="Update Record" data-toggle="tooltip">Add Button</a>';
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
} else {
echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
}
} else {
echo "Oops! Something went wrong. Please try again later.";
}
// Close connection
mysqli_close($link);
?>