Diegar Posted October 6, 2007 Share Posted October 6, 2007 If i have a table with 4 rows, 0, 1, 2 and 3, and i delete row 2, i am left with 0, 1 and 3. Is there a quick way to close that gap, leaving me with 0, 1 and 2? Link to comment Share on other sites More sharing options...
Diegar Posted October 6, 2007 Author Share Posted October 6, 2007 Finally figured it out. $getIDquery = "SELECT id FROM $user ORDER BY id"; $getID = mysql_query($getIDquery,$msa) or DIE (mysql_error()); $remNum = mysql_numrows($getID) or DIE (mysql_error()); while($downLine <= $remNum) { $setNew = "UPDATE $user SET id = '$line' WHERE id = '$downLine'"; mysql_query($setNew) or DIE (mysql_error()); $downLine++; $line++; } When i removed the row in previous code, $line was the row id number. If row 2 was deleted, '$line = 2' from POST. $downLine = $line + 1Hope that helps anyone with a similar issue. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.