我真的需要帮助来修复此代码。 Actualy我想从表中获取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'];
}