Oh, ok. Well, instead of using a for loop, you can step up to a while loop:
while ($row = mysql_fetch_row($res)){
print $row['field1'];
// more stuff goes here...
}
and you can walk right through your results.
Throw off the shackles of the for loop! (hehe, only kidding 🙂
If you want a for loop, you can do it like this:
$count = mysql_num_rows($res);
for ($i=0;$i<$count;$i++){
$row = mysql_fetch_row($res,$i);
// do more stuff here.
}
But take my word for it, trying to keep your ids in order is a recipe for disaster. Imagine if the airline reservation system went offline for 2 hours every night to do something similar? People would freak. And while your system today may not have that much load, planning on always being able to lock everyone out to reorder old ids just to make your code happy is a bad idea.