Question

$users = explode(",", $particiTemp);
                foreach($users as $user) {
                    echo "$user";
                }

                $checkSQL = mysql_query("SELECT * FROM this WHERE x>'$y' && v<'$z' &&  user IN ($particiTemp)");
                while($checkData = mysql_fetch_array($checkSQL)){

                }

I´m kinda stuck right here...

I want to check if $particiTemp (for example: $particiTemp = "2,23,11,4,") is in the field $checkData[user] ($checkData[user] = "5,22,11,23";).

I tried to explode both and tried mysql IN but I don´t know how to check if the field $checkData[user] CONTAINS one of the imploded $particiTemp

Was it helpful?

Solution

"In" clause need values as '2','23','11','4' instead of "2,23,11,4,"

so manipulate your array for result.

$innval = '';
foreach($users as $user) {
  if($user != '')
    $innval .= "'".$user."',";
}
$innval = substr($innval,0,-1);  // to remove last extra ,

and now use this $innval variable in your query to get result

$checkSQL = mysql_query("SELECT * FROM this WHERE x>'$y' && v<'$z' &&  user 
IN ($innval)");

Hope this helps

OTHER TIPS

Idea: explode array to check, for each a mysql_query with INSTR.

Should work, trying it now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top