I added a field labeled 'box_num' into the existing database. Each entry has it's own id labeled 'id'. Each entry has one of two possible types, '20' or '30'.
My script runs two select queries, storing 'id' for each '20' entry in an array, and each '30' entry into a different array. I am then attempting to assign each entry a 'box_num' based upon its 'id' value. I am looping through the arrays as follows:
Expand|Select|Wrap|Line Numbers
- for ($x = 0; $x < count($twentyArray); $x++) {
- $sql2 = ("UPDATE $db.boxes
- SET box_num = '".$twenty."'
- WHERE id = '".$twentyArray[x]."'");
- $res2 = mysql_query($sql2) or die(mysql_error($mysql));
- $twenty += 1;
- }
- for ($y = 0; $y < count($thirtyArray); $y++) {
- $sql3 = ("UPDATE $db.boxes
- SET box_num = '".$thirty."'
- WHERE id = '".$thirtyArray[y]."'");
- $res3 = mysql_query($sql3) or die(mysql_error($mysql));
- $thirty += 1;
- }
1) The $twentyArray and $thirtyArray are being populated
2) The $twenty and $thirty values begin at 2000 and 3000, respectively. The loops are iterating through each variable, because when I echo the value of each variable at the end of the script, it prints the value increased by the correct number of entries for the specific type.
I can only assume that the problem is with my WHERE clause.
Does this make sense?
Can anyone help me?