我正在尝试检查用户是否在 SQL 表上有一个特定的字母,例如:
我有 SQL 表 amx_amxadmins 和列 id、用户名、访问示例:
amx_amxadmins:
--------------------------------------------------
| ID | USERNAME | ACCESS |
--------------------------------------------------
| 1 | TEST1 | abcde |
--------------------------------------------------
| 2 | TEST2 | bcde |
--------------------------------------------------
标志 A 用于No Access。
那么我如何检查用户是否在列访问 A 或没有?
例如:
<?php
$check_user_flag = $mysqli->query("SELECT * FROM `$amxadmins` WHERE `username` = '$logged[username]' AND `access` LIKE 'a' ") or die(mysqli_error($mysqli));
$checkUSRFLAG = $check_user_flag->fetch_assoc();
if($checkUSRFLAG->num_rows > "a"){
echo "test";
}
else {
echo "test2";
}
?>
```
由 RyffLe 编辑
$query = "SELECT * FROM `$amxadmins` WHERE `username` = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('s', $param);
$param = $logged['username'];
$stmt->execute();
$result = $stmt->bind_result();
$stmt->close();
$Permissions = $obj->access;
if (strpos($Permissions, 'a')) {
echo("An A has been found!");
}
else {
echo("An A wasn't Found...");
}
梦里花落0921
江户川乱折腾