I'm trying to update a column in a table with either a 1 or a 2. I figured I'd try it try a simple select statement and an update statement to follow.
The part I get messed up on is inserting a "1" for the first record that shows, then inserting a "2" for the next record that shows, then inserting a "1" for the following record, and so on.
Here's what I have so far:
$sql = mysql_query("SELECT ID FROM table");
while ($row = mysql_fetch_array($sql)) {
$numnum = (0 % 2) ? 1 : 2;
$ID = $row['ID'];
$sql_3 = "UPDATE table SET column = '$numnum' WHERE ID = '$ID' ";
mysql_query($sql_3,$connection);
}
So far, all records are getting a number 2 in the column.
Can someone see what I've got wrong in my queries? Or if there's a better way?
thanks a ton!