gpt4 book ai didi

每行表格上的 PHP 按钮

转载 作者:行者123 更新时间:2023-11-29 00:40:32 25 4
gpt4 key购买 nike

我正在用 PHP 制作一些申请表。

我将从数据库返回的所有信息放入一个表中。

现在我想在每一行上创建一个按钮来更改该行数据库中的某些内容。

但我不知道该怎么做:S

谢谢!

echo "<table border='1'>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>age</th>
<th>position</th>
<th>experience</th>
<th>motivation</th>
<th>date</th>
<th>status</th>
<th>test</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['position'] . "</td>";
echo "<td>" . $row['exp'] . "</td>";
echo "<td>" . $row['motivation'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>" . '<input type="submit" name="submit" value="accept">' . "</td>";
echo "</tr>";

}
echo "</table>";

编辑:使用另一个脚本让它工作:

echo "<td><a href=\"edit.php?id=".$row['id']."&status=app\">Approve</a></td>";

和 edit.php:

<?php
include("dbconnect.php");
$member_id = $_GET['id'];
$status = $_GET['status'];
echo $member_id;
echo $status;
if ($status == 'app')
$query = "update apps set status = 'approved' where id = $member_id";
mysql_query($query) or die (mysql_error());
?>

最佳答案

在您希望按钮执行 smth 的单元格中使用参数创建小表单。这是最简单的方法(带刷新的方法)。

另一种解决方案是在单击按钮并将操作转发到某个端点时使用 AJAX。这样它将是动态的,并且可能是您想要实现的。

关于每行表格上的 PHP 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12462899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com