I have 2 equal arrays. 1 has ID values for the database table and the other has the corresponding update data. The array lengths keep changing as new data at different times is updated. However they will always be equal. How do I go about updating my mysql database table by extracting each ID from the array and then use that to commit the necessary update with the corresponding data in another array. Below is what I have tried but It only updates the last element and nothing else:
$arraysIDs; //array containing database table IDs
$arrayVALUES; // array containing update data
for ($x = 0; $x < count($arraysIDs); $x++){
$element = "UPDATE TableToUpdate SET
newUpdateData = '$arrayVALUES[$x]'
WHERE ID = $arraysIDs[$x])";
}
Thank you for your help.