Hello all, I have a section on a site I am building which has visibly allocated numbers to each database entry. These numbers are editable to move an item up or down on a list.
The problem I am trying to solve is the ability to have consistent numbering, ie. 1,2,3,4,5,6... Currently, a user can enter any number in so it can end up jumbled, such as this 0,4,9,12,16,20,22....
Any ideas on how to do this?
Consistent Numbering
Moderator: General Moderators
- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
Code: Select all
$sql = "select id from table order by order_id";
$result = mysql_query($sql,$databaseConnection);
while ($record = mysql_fetch_object($result)) {
$sql = "update table set order_id = ".++$o." where id = ".$record->id;
mysql_query($sql,$databaseConnection);
}- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
its to do with the priority listings i was asking about around 3 weeks ago, it is separate to the ID of each field, after time it will all work out, but if for example someone accidentally enters in a 14, when they meant to enter 4, i would like it to jump back to the end of the consistent numbers ie. 1,2,3,4.feyd wrote:Users are allowed to specify the order number to create an entry under?