Page 1 of 1

Make a row increase every time the same value is added to th

Posted: Tue Jul 27, 2010 8:05 am
by dominod
Hi

Is it possible to make a row(with number) increase every time the same value is added to the table?

Example:

I enter "test" into a table and it gets the following data:

id=1 name=test count=1

And the next time I enter "test" into the table it becomes

id=1 name=test count=2

instead of

id=1 name=test count=1
id=2 name=test count=1

I want to create a form where users can suggest stuff and I want to see what is the most popular ect.

Thanks in advance :)

Re: Make a row increase every time the same value is added t

Posted: Tue Jul 27, 2010 8:23 am
by Benjamin
One solution would be to add a unique index to the name field, or whatever it is, then use the ON DUPLICATE KEY UPDATE mysql syntax. You can find examples of this on the mysql website.

Re: Make a row increase every time the same value is added t

Posted: Sun Aug 01, 2010 1:19 pm
by dominod
Thanks :D