我对编码很陌生,所以请轻轻地去...
我正在创建一个管理页面,其中包含需要验证的帐户列表。我所需要的只是在单击按钮时将数据库“已验证”列中的值从0更改为1。问题在于,它为循环中所有其他返回的结果触发相同的操作,每个结果都有自己的按钮,而不仅仅是循环的特定迭代。任何帮助将不胜感激。代码目前如下所示:
<?php
$sql ="SELECT customer.First_Name, customer.Last_Name, account.account_no, account.client_id, customer.username
FROM customer
INNER JOIN account
ON customer.customer_id=account.client_id
WHERE validated = 0";
$tobe_validated = $dbh->query($sql);
foreach ($tobe_validated as $row) {
//creating variable for account number to put in query
$clientid=$row["client_id"];
echo "<div class='valid_name_btn'>";
echo "<form method='post'><input type='submit' class='btn btn-outline-primary' value ='Validate' name='validate' id='validate'></input></form>";
echo "<div class='valid_name'>"; //div for name
echo $row["First_Name"] . " " . $row["Last_Name"]." - Account No. ". $row["account_no"]."<br/>"; //show name and account number of client
echo "</div>";
echo "</div>";
// query to change validated in customer table to 1
$sql ="UPDATE customer SET validated = 1 WHERE customer_id = '$clientid'";
// validate account when button is clicked
if(isset($_POST['validate'])) {
$dbh->query($sql);
}
}
皈依舞
小唯快跑啊
素胚勾勒不出你
慕田峪4524236