I would think you're trying to build an SQL query with a WHERE clause something like this:
But you need to change the "something" and "somethingElse" into the indices of your array subjectNames, so
But this has two problems: you does know how long the array subjectNames is, and building an SQL query like this (concatenating strings) leaves you open to SQL injection attacks. So I think you need to build the WHERE clause something like this:
Then using a prepared statement, add the subjectNames indices to the statement.
Does this make sense to you? I'll try to add code in another reply if I have time.
All things are lawful, but not all things are profitable.