gpt4 book ai didi

php - MySQL:当通过 $_GET 变量执行查询时,行没有更新

转载 作者:行者123 更新时间:2023-11-29 07:57:54 25 4
gpt4 key购买 nike

我的 MySQL 查询再次出现问题。我正在尝试使用 $_GET 变量执行查询。这是我的代码。非常感谢,非常感谢您的回答。

如果有人认为我的问题不正确,请不要否决我的问题,请编辑它或告诉我编辑它。

非常感谢。这是代码。

 $Status = $_GET['status'];
$User = $_GET['user'];

require('./connect.php');
$query = "SELECT * FROM users ORDER BY id ASC";
$result = mysqli_query($con, $query);
$numrows = mysqli_num_rows($result);
if ($numrows > 0) {
echo '<table class="table" border="1">
<tr style="background-color: #0DF; color: #222; font-weight:bold;">
<td>ID:</td>
<td>User Name:</td>
<td>Email:</td>
<td>First Name:</td>
<td>Last Name:</td>
<td>Domain:</td>
<td>Country:</td>
<td>Phone:</td>
<td>Plan:</td>
<td>Duration:</td>
<td>Payable:</td>
<td>Paid Date:</td>
<td>Active Plan:</td>
<td>Active:</td>
<td>Register Date:</td>
</tr>';

while ( $row = mysqli_fetch_assoc($result) ) {
$dbid = $row['id'];
$dbuser = $row['username'];
$dbemail = $row['email'];
$dbfname = $row['first_name'];
$dblname = $row['last_name'];
$dbdomain = $row['domain'];
$dbcountry = $row['country'];
$dbphone = $row['phone'];
$dbplan = $row['plan'];
$dbduration = $row['duration'];
$dbpayable = $row['payable'];
$dbpaid_date = $row['paid_date'];
$dbactive_plan = $row['active_plan'];
$dbactive = $row['active'];
$dbdate = $row['date'];
if ( $dbactive_plan == 0) {
$status = "Activate";
$changeStatus = '<a href="http://www.mydomain.com/admin.php?status=1&user='.$dbuser.'">'.$status.'</a>';
}
else {
$status = "Deactivate";
$changeStatus = '<a href="http://www.mydomain.com/admin.php?status=0&user='.$dbuser.'">'.$status.'</a>';
}
echo '
<tr>
<td>'.$dbid.'</td>
<td>'.$dbuser.' <a href="http://www.mydomain.com/admin.php?id='.$dbid.'">Delete</a></td>
<td>'.$dbemail.'</td>
<td>'.$dbfname.'</td>
<td>'.$dblname.'</td>
<td>'.$dbdomain.'</td>
<td>'.$dbcountry.'</td>
<td>'.$dbphone.'</td>
<td>'.$dbplan.'</td>
<td>'.$dbduration.'</td>
<td>'.$dbpayable.'</td>
<td>'.$dbpaid_date.'</td>
<td>'.$dbactive_plan.' '.$changeStatus.'</td>
<td>'.$dbactive.'</td>
<td>'.$dbdate.'</td>
</tr>';


}//while loop
echo '</table>';
if ($Status == 1 && $User == $dbuser) {
$query = "UPDATE users SET active_plan='$Status' WHERE username='$User'";
mysqli_query($con, $query);
echo "$Status";
}
else if ($Status == 0 && $User == $dbuser) {
$query = "UPDATE users SET active_plan='$Status' WHERE username='$User'";
mysqli_query($con, $query);
echo "$Status";
}

已更新

最佳答案

您在 while 循环内定义 $dbuser,因此它被设置为循环上次迭代中的用户名。根据您的代码,我不确定 $dbuser 应该是什么,根据您的代码判断......

关于php - MySQL:当通过 $_GET 变量执行查询时,行没有更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24616469/

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