2 回答
TA贡献1772条经验 获得超6个赞
首先,欢迎访问 Stackoverflow Beytula Ibryam。
那是你的桌子:
amx_amxadmins:
--------------------------------------------------
| ID | USERNAME | ACCESS |
--------------------------------------------------
| 1 | TEST1 | abcde |
--------------------------------------------------
| 2 | TEST2 | bcde |
--------------------------------------------------
首先,您需要从您的数据中选择您需要检查的所有用户数据:
$query = "SELECT * FROM `$amxadmins` WHERE `username` = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('s', $param);
$param = $logged[username];
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
$obj = $result->fetch_object();
接下来是将您的访问权限作为字符串:
$Permissions = $obj->access;
现在我们可以去检查您想要的文字的访问权限:
if (strpos($Permissions, 'a')) {
echo("An A has been found!");
}
else {
echo("An A wasn't Found...");
}
享受 ;)
--- 编辑 ---
$query = "SELECT * FROM `?` WHERE `username` = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('ss', $amxadmins, $logged['username']);
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
$obj = $result->fetch_object();
if($checkUSRFLAG->num_rows > "a"){
echo ("test");
}
else {
echo("test2");
}
如果您没有 MySQLi 连接文件,请将以下几行添加到您的主文件中:
$mysqli = new mysqli('YOUR_DATABEAS_IP', 'YOUR_DATABEAS_USER', 'YOUR_DATABEAS_USER_PASSWORD', 'YOUR_DATABEAS_NAME', 'YOUR_DATABEAS_PORT');
if($mysqli->connect_error) {
exit('Error connecting to database'); //Should be a message a typical user could understand in production
}
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
TA贡献1851条经验 获得超5个赞
听起来您只是在寻找通配符搜索。%
为此使用字符。所以而不是这个:
AND `access` LIKE 'a'
你会有这个:
AND `access` LIKE '%a%'
- 2 回答
- 0 关注
- 129 浏览
添加回答
举报