我真的需要帮助来修复此代码。实际上我想从用户从表类别中选择几个类别的表中获取 gcm_id。我想要的重点的一个例子是 gcm_id 数据“gcm_id 将显示用户是否选择类别 A、B、C”等。我如何在 php mysql 中执行此操作。我尝试 FIND_IN_SET 没有运气
uid | email | gcm_id | app_type | categories
1 demo@gmail.com xzxzxzxz A 2,5,6
如果用户已选择类别 id 2、5 和 6,如何获取 gcm_id?
编码 :
if (!empty($cat)) {
foreach ($cat as $key => $value) {
$wc.="FIND_IN_SET('$value',categories) > 0 OR ";
}
}
$pos = strrpos($wc, "OR");
if ($pos !== false) {
$wc = substr_replace($wc, "AND", $pos, strlen("OR"));
}
$wc.=" is_active=1";
$q = "select * from datanotif where app_type='$type' AND $wc ";
$r = mysqli_query($mysqli,$q);
$users = array();
while ($row1 = mysqli_fetch_assoc($r)) {
$users[] = $row1;
}
$ids = array();
foreach ($users as $key => $value) {
$ids[] = $value['gcm_id'];
}