我的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";
}
已更新
答案 0 :(得分:2)
您在$dbuser
循环中定义了while
,因此它将被设置为循环最后一次迭代的用户名。根据您的代码,我不确定$dbuser
应该是什么,根据您的代码判断....