我已经创建了一个更新功能,但不喜欢它的出现方式,我让用户输入第一个,最后一个和特许经营名称,但老实说没有意义。我需要让用户选择要更新的名称然后编辑需要更新的字段但不太确定如何执行此操作?你能帮我搞清楚这个吗?有什么建议吗?
<!DOCTYPE html>
<html>
<body>
<h1>Franchise Call Log</h1>
<?php
$con=mysqli_connect("");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM caller_info");
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Franchise</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Firstname'] . "</td>";
echo "<td>" . $row['Lastname'] . "</td>";
echo "<td>" . $row['Franchise'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
<h1>Insert a New Caller</h1>
<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname">
Lastname: <input type="text" name="lastname">
Franchise: <input type="text" name="franchise">
<input type="submit" name="submit">
</form>
</body>
</html>
<html>
<body>
<h1>Delete a Caller</h1>
<form action="delete.php" method="post">
Lastname: <input type="text" name="lastname">
<input type="submit" name="submit">
</form>
</body>
</html>
<html>
<body>
<h1>Update a Caller</h1>
<form action="update.php" method="post">
Firstname: <input type="text" name="firstname">
Lastname: <input type="text" name="lastname">
Franchise: <input type="text" name="franchise">
<input type="submit" name="submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>Your records have been updated</h1>
<?php
$con=mysqli_connect("localhost","tt2^homas12","password","tt2^homas12");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE Caller_info SET Firstname = '$firstname' WHERE Lastname
= '$lastname'");
mysqli_close($con);
?>
</body>
</html>