How to process array element into mysql with php?
I want to get elements of an array, and put it to mysql query using php
like this:
$ArrayOne = {3, 5, 8, 2};
$sql = SELECT * from myTable WHERE id1=3 and id2=5 and id3=8 and id4=2;
I do it like this, but it's failed :
for ($i=0; $i<count($ArrayOne); $i++) {
$element.$i = $ArrayOne[$i];
}
$sql = SELECT * from myTable WHERE id1=$element.$i and id2=$element.$i
and id3=$element.$i and id4=$element.$i;
I think the $element.$i has the same value, but i don't know how to get
the different value of Array element .... And if i do like this, it's also
wrong ....
for ($i=0; $i<count($ArrayOne); $i++) {
$element.$i = $ArrayOne[$i];
$sql = SELECT * from myTable WHERE id1=$element.$i and id2=$element.$i
and id3=$element.$i and id4=$element.$i;
}
Can any body give the solution ? thank you
No comments:
Post a Comment