Question: I've been trying to sort this out for weeks, but can't get anywhere. 
My issue is that I have an array in javascript but the individual phrases in the array also have commas in them. 
I am passing the array as a variable to php using POST and php is exploding the array into variables, but is also separating parts of the array members that have a comma.

Step 1: Array in javascript

```
wrongOnes = ("blah blah blah", "bing, boing, bing");

```

Step 2: read by php

```
$myArray = explode(',', $_POST["wrongOnes"]);

```

Step 3: this is then made into a message to be posted

```
foreach($myArray as $my_Array){
$message .= "\r\n".$my_Array;  
}

```

You can see that the problem is exploding and separating at the commas makes extra members of $myArray.

I feel that the answer should be easy, but my current level of php is weak. Can anyone help?

Cheers

Charco.

Answer: 
The most obvious issue is that your filters are never applied, because $gendre, $country and $year are never passed to the function.

Assuming that you read those values correctly from the request object, look at the tags in the HTML, you never set name attribute for either of them, so I think they are never passed to the code correctly if you use regular submit. It is a bit hard to say, because we cannot see the jQuery code, but that is where the problem is I think - in jQuery building your request parameters. 

To fix paging, when you are building query like this:

```
   $query  .= " and m_country in('$countrydata') LIMIT {$startpoint} , {$per_page} "; 

```

first, add only filter:

```
   $query  .= " and m_country in('$countrydata') "; 

```

and then after all filters are done, before executing your query add this:

```
   $query  .= " LIMIT {$startpoint} , {$per_page} "; 

```

For debugging purposes consider printing out the value of $query just before this line: 

```
   $rs = mysqli_query($mysqli,$query) or die("Error : ".mysqli_error($mysqli));

```

And compare them on page 1 and page 2 to see if anything sticks out as a sore thumb.
Tadasbub's answer should be sufficient. I just write out the changes based on his suggestions.

```
              <?php 

             $query = "SELECT * FROM movies 
      WHERE movie_status = '1'"; 
              //filter query start 
              if(!empty($genre)){
                  $genredata =implode("','",$genre);
                  $query  .= " and m_genre in('$genredata')"; 
              }

               if(!empty($country)){
                  $countrydata =implode("','",$country);
                  $query  .= " and m_country in('$countrydata')"; 
              }

              if(!empty($year)){
                  $yeardata =implode("','",$year);
                  $query  .= " and m_year in('$yeardata')"; 
              }
            //filter query end 
             $query .= " LIMIT {$startpoint} , {$per_page} ";
             $rs = mysqli_query($mysqli,$query) or die("Error : ".mysqli_error($mysqli));

```

Just change the query block as written over here. It should work as you expected.

BTW, the problem is only with php logic. It is not related to sql/mysql.