My problem is, i want to update the database by renumbering all fields, heres what i got
$unique
$q=mysql_query("SELECT * FROM table WHERE something='$unique'");
$p=0;
while($r=mysql_fetch_array($q)){
$p++;
print $p;
mysql_query("UPDATE table SET field='$p' WHERE something='$unique'");
}
Obviously this script creates a loop where 'field' gets updated as many times as there are rows and ends up updating all 'field's to the same value
What i want it to do is update each field to reorder that field so if the fields in order were 1,2,5,6 it would change them to 1,2,3,4.