Problem:
Formats and topics produces arrays derived from an AJAX post
Proposed Solution:
Break the array into individual strings and compare each string with its respective query item using php internal function in_array
However, I am not sure how to implement it.
Below is the code:
  $formatsArray = $_POST['formats'];
  $topicsArray = $_POST['topics'];
I am using in_array because Implode did not work:
  $formats = implode('","', $formatsArray);
   $topics = implode('","', $topicsArray);
   $resources = "select * from resources where
                 stage LIKE '%".$stage."%'
                 AND format IN(".$formats.")
                 AND topic IN(".$topics.") ";
stage is just a string not an array.
I would like to use in-array within the query,
How the array is created (in javscript):
optionScope = $(this);
// Stage 4 option A
var formats = [];
optionScope.data().formats = formats;
stage4_optiona.on('click', function(){
  continue4.css('opacity', '1');
    continue4.on('click', function(){
    optionScope.data().formats.push("Online classroom");
        stage5.show();
        stage4.hide();
    });
});
then post
  <script type='text/javascript'>
        /* attach a submit handler to the form */
$(function(){
  optionScope = $(this);                    // wait until dom is ready
$("#formMail").submit(function(event) {
  /* stop form from submitting normally */
  event.preventDefault();      /* stop form from submitting normally */
          $.ajax({
              url: "functions/contact.php",
              type: "post",
              data: {stage : optionScope.data().stage,
                    topics: optionScope.data().topic,
                    formats: optionScope.data().formats,
                    fname: $('#fname').val(),
                    email: $('#email').val(),
                    humancheck: $('#humancheck').val()
                  },
              success: function (response) {
                  console.log("data sent successfully");
                  window.location = response;
              },
              error: function (xhr, desc, err) {
                  console.log(xhr);
                  console.log("Details: " + desc + "\nError:" + err);
              }
          });
                  });
  });
</script>
Update:
Array( 
  [0] => Videos 
  [1] => Blogs/articles 
  [2] => books
)
Array(
 [0] => idea generation 
 [1] => mindset 
 [2] => psychology
) 
 
    