This is driving me nuts I am so close. Please help!!
I made a web page with a few drop down boxes. some of which have a selection of ALL.
I have a js array like
sitesArray = [1,2,3,4,5,6]
I turn the js array into a comma delimited string: var sitesStr = sitesArray.join(‘,’)
and I use jquery to post the string to PHP.
On the PHP side:
I grab the post variable and turn it into a php array:
$siteArray = explode(‘,’,$_POST[‘sitesStr’]);
This is to be used in the where clause of a sql query.
Calling one variable from the array works.
$position = “pl.position = '” . $siteArray[5] . "’ ";
Output is 6
Trying to append string to a variable behaves unexpectedly.
At the start of the loop, $i is set to zero. Then the condition is checked, is $igreater than the number of items in the array? No, it never will be! Since the condition is not true, the loop contents never get executed.
A simple mistake, just flip the operator around to be less than ($i < count(…)).