我有一个简单的表格,每行都有一个接受和拒绝按钮。如果您按接受,我需要它根据唯一引用将 10 添加到 MYSQL 列。如果拒绝添加具有相同引用的 20 个(每行一个),我有以下代码来创建表格和按钮。(连接等已取出)
<form Action="leaveupdate.php?" method="POST" >
$query= "
SELECT t0.*, t1.id_user as t1user, t1.name as t1name
FROM $loc t0
LEFT JOIN login1st t1 ON t0.User_id = t1.id_user
WHERE t0.status >=10 and status <20 ORDER BY Date_Input ASC
";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$fieldCount = mysql_num_fields($result);
echo "<TABLE border='1' cellspacing='0' cellpadding='15' id='sort_table' width='490px'> <thead><TR bgcolor=#ffffff>";
?>
<legend>Research results!</legend>
<table border="1" width="75%" cellpadding="2" cellspacing="0">
<tr>
<TD align="center">Requestor</TD>
<TD align="center">Leave type</TD>
<TD align="center">Date requested</TD>
<TD align="center">Date Requested</TD>
<TD align="center">ACCEPT</TD>
<TD align="center">DECLINE</TD>
</tr>
<?
echo "</TR></thead><tbody>";
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo'<td align=middle>' . $row["t1name"] . '</td>' ; // Requestor
echo'<td align=middle>' . $res . '</td>' ; // Status
echo'<td align=middle>' . date("l", $row["date_effected"]) . "<BR>". date("j-M-Y", $row["date_effected"]) . '</td>' ; // Day off
echo'<td align=middle>' . date("d-m-y @ H:i", $row["Date_Input"]) . '</td>' ; //Date Requested
echo'</td><td><input type="submit" name="edit" value="10" class="buttons2">';//Add 10
echo'</td><td><input type="submit" name="edit" value="20" class="buttons3">';//Add 20
echo'<td alighn=middle>'.$row["Unique_id"].'</td>';Just for testing not needed will be removed from the table
echo '</tr>';
}
echo "</tbody></TABLE>";
?>
</table>
</body>
</html>
这已发布(我使用 get 来查看会发生什么但会更改)到此页面
<?php
$loc = $fgmembersite->UserLocation();
$conn = mysql_connect("****","******","Pword");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db("****",$conn) or die ("Could not open database");
if(!isset($_POST['edit']))
{
//add die here
}
$IU = ($_POST['Unique_id']);
$change = ($_POST['edit']);
$sql_query_update = "update $loc set status = status+$change where unique_id = IU";
mysql_query( $sql_query_update );
echo $sql_query_update;//only for testing will be removed
mysql_Close()
?>
如您所见,我希望有两个变量 IU 和更改,但无法弄清楚。可能很容易,但如果有人可以提供帮助,那将很有帮助。我一直在阅读网络并看到对 AJAX 的引用,但从未使用或研究过它。谢谢京东