How the Ajax product screening function is judged 
This post was last edited by q5975166 on 2014-07-07 19:49:42 
I put the various options for filtering items into a field in the database as JSON (Cp_leibie) 
For example, I saved 3 records. 
Their option is to 
{"208": ["209"], "5": ["182"], "6": ["30"], "27": ["36"], "28": ["34"]} if the data ID of the bar is 1 
{"92": ["201", "202", "204"], "93": ["137", "138", "139"], "94": ["143", "144"]} if the data ID of the bar is 2 
{"208": ["209"], "5": ["182"], "6": ["29"], "27": ["35"], "28": ["33"]} if the data ID of the bar is 3 
Loop through the array when it is removed 
----------------------------------------------------------------- 
For example, one of the options in the product is (applicable environment: all Office Modern European) 
Then $PEISTR is the "applicable environment" ID, $LIESTR is the ID of the subsequent sub-option, 
Specifically how to receive it is not posted out, 
Why minus two in the following for loop is not considered. 
The following is the AJAX submission of past query statements: 
 
$strpei = "Select ' id ', ' name ', ' Huiyuanjia ', ' cpimg ', ' Shichangjia ', Cp_leibie  from  '". $db _prefix. " Chanpin ' where ' Ifxianshi ' =1 and ' cpfl ' = ' ". $sid." ' ";
$DQCP = $Db->fetchall ($strpei);//This is the way to execute the SQL statement
$strpei. = "and ID in (";
$strpei 2 = "";
foreach ($dqcp as $dkey = + $dvalue) {//Traverse all products
$darr =json_decode (UrlDecode ($dvalue [' Cp_leibie '), true);//decode JSON data
for ($i =0; $i
 
  
foreach ($darr [$PEISTR [$i]] as $dddkey = + $dddvalue) {//The decoded data is traversed, and the key name is the ID of the Received commodity option
if ($liestr [$i]== $dddvalue) The ID of the {//Sub-option is consistent with the value in the JSON data, the ID of the data is added to the condition
$strpei 2.= $dvalue [' id ']. ",";
}
}
}
}
$strpei. = $strpei 2. ")";
 
The ID of the corresponding product is written into the in grammar of the condition according to the condition. 
If you click on a subkey of 209, then IDs 1 and 3 will be added to the condition 
The problem is that the first time you receive a second time when you click 201, there should be no qualifying data, but the data for the 3 IDs is displayed. 
Should be in the loop if the judgment is not written right, do not know the conditions to write. Or somewhere else to work it out. 
------Solution-------------------- 
I changed my judgment a bit. 
 
if ($liestr [$i]== $dddvalue) {
$strpei 2.= $dvalue [' id ']. ",";
 
 
 
$where. = "$liestr [$i]== $dddvalue &&";
if ($i = = (count ($peistr)-2)) {
$where = substr ($where, 0,-2);
}
if ($where) {
$strpei 2.= $dvalue [' id ']. ",";
}
 
But in this case, $where he is a string to be judged in the IF. No judgment can be processed no matter what $where is 1. It's just a thought, you see.