Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-Numbering of a list from the database:

Status
Not open for further replies.

mancroft

Programmer
Joined
Oct 26, 2002
Messages
267
Location
GB
Re-Numbering of a list from the database:

I have printed out on screen the contents of a mySQl database thus:

1. item1
2. item2
3. item3
4. item4

I then delete item3 so the list now looks:

1. item1
2. item2
4. item4

Is there any way to reset the numbers so they are in sequence thus:

1. item1
2. item2
3. item4

?

Thanks!
 
If you are talking about renumbering a database column, I wouldn't bother. It's not worth the effort to do it, particularly if this table is related to others.

If you're worried about running out of numbers, use a column type of BIGINT UNSIGNED. That will give you a range of 0 to 18,446,744,073,709,551,615 available in that column.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
just use a counter for the number

Code:
$x=1;//counter
while ($rows=mysql_fetch_array($result)){

   echo $x>") ".$rows['item'];

   $x++;

}


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top