Help with a minor problem please?

Yup, I just need to know how to auto increment with php and mysql. What I need is, each time something is inserted into my database then it auto increments the first entry on the list, then once the first entry has 5 then it will delete first entry and start with the next on the list. So in the example below name 1 would have 5 and then be deleted and then it will start on name 2.


Name Status

name 1 5

name 2 0

name 3 0

name 4 0

name 5 0

Name 6 0

You need to be more specific because what was said makes very little sense.

I read that like 5 times and still couldn’t figure out what the op is talking about lol.

for each item that is inserted in the database, the first row increments once

( sigh )

ok so you have a mysql table that looks like:

name age status

person1 21 0

If I were to insert another persons data into the database then it would look like:

name age status

person1 21 1

person2 35 0

And if I added another:

name age status

person1 21 2

person2 35 0

person3 16 0

How would I do this? I am trying to be as clear as possible, I am a beginner so I do not know the correct lingual to use

That seems a little awkward. Why exactly does this need to be done?

why would everybody being added to this table have the name “person”??

i think that’s your problem, and the fact that you want to “increment” a name column

why not use an ordinary integer auto_increment column?

I doubt you can do the incrementing and deleting using just sql. When you want to enter another name, first run a query to see how many records there are in the table already with that name. If it’s less than 5, then just add the new record. Otherwise run a query to delete the records you need to delete and then run a query to insert the new record with the appropriate values for each column in the table. In your case, all the appropriate incrementing will have to be done in php after you run the first query to see how many records you have with a particular name.