PDA

View Full Version : question about numbering record in a better way


bbmak
08-10-2005, 10:17 PM
hi:
right now i am using this to number my records. Are there any better way or functions to number records?
i=1;
while () {
echo "$i";
i++;
}

CrzySdrs
08-10-2005, 10:28 PM
What kind of records are you numbering? If they are coming from a db, you could just have it so that it prints out a number when every row is used.

If you are just outputting numbers with no data, I don't really see the point. I assume since you are dynamicly generating numbers, you have data to go with it.

If we see more code, we could make a better assumption.

bbmak
08-10-2005, 10:30 PM
What kind of records are you numbering? If they are coming from a db, you could just have it so that it prints out a number when every row is used.

If you are just outputting numbers with no data, I don't really see the point. I assume since you are dynamicly generating numbers, you have data to go with it.

If we see more code, we could make a better assumption.

yes it is records from database. how do i number them in a better way?

mrruben5
08-10-2005, 11:24 PM
Running mysql? make a field id, and auto_increment it.

marek_mar
08-10-2005, 11:48 PM
It's a good way if you wan't to number them display wise eg. for an ordered list.

bbmak
08-10-2005, 11:58 PM
Running mysql? make a field id, and auto_increment it.

for my auto_increment, it is not really in order, some records in the middle have deleted

raf
08-11-2005, 12:08 AM
i don't quite understand what you need.

in your db, you usually make the Primary Key in your table an auto_increment. Because it is used to define relationschips with other tables (through Primary Key - Foreign Key relationships), you can not change it to have a nice sequence without any missing number. It's also irrelevant then that there are holes in the sequence.

or are these numbers supposed to indicate some sort of usable order?