I have an array which contains numbers like “331,554,22” or it could be “45”, lets say the array is called $numbers.
I want to loop through the array and for each number or entry in it, do a SQL query like
UPDATE members SET x=1 where id=$numbers[x]
Could someone help me along?
UPDATE: Also, say I store the query values in a text field in my database called nums and it looks like eg. “45,656,23”, how would I convert that to an array format?
if the veriable
"331,554,22"is not an array (string),explode it first
and then.
Foreach :
For :
if x is always 1 you can use in,
and if the
$numbersvariable is string, andxwill be1for each ID, forget all of I wrote and try this only 🙂