Jump to content


Photo

PHP / MYSQL Adding to ID Number


  • Please log in to reply
2 replies to this topic

#1 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 29 September 2006 - 06:06 AM

I am adding a private messaging system to my website, and am wondering, how do I add a distinct ID number to each message. I  have a column named ID in a table called messages in a database called test. I want it to be so the first message will have id = 1, seccond message id = 2, and so on and so forth. Is this easy? How would I do it?

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 29 September 2006 - 06:12 AM

cast it as an INT type, add the AUTO_INCREMENT attribute, and make it a PRIMARY KEY.  simple as that.

#3 RTS

RTS
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 29 September 2006 - 06:15 AM

yes! thank you!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users