I notice that in WP blogs the comments order by continuous id (id=203, id=204 and so..). while I understand the class names "parent" "child" - to sort the reply to thread, I didn't figure out why the id's are continuous - maybe to choose hide/show specific comments?
+2
A:
You need to improve your question.
Comments have UNIQUE IDs because they are stored in their own table, and a One to Many relationship links the Posts with the Comments, thus, having a 'global' counter to them.
Comment ID 1 => Post ID 1
Comment ID 2 => Post ID 1
Comment ID 3 => Post ID 2
And so on, Post 1 has 2 comments, post 2 has one.
F.Aquino
2010-02-27 04:06:37
but the relation between comments to post can be set in the server side script, like you said. each comment has a relate id to the post.what I meant to ask is why it has a unique ID in the html.like in this WP blog:http://www.smashingmagazine.com/2010/02/24/smashing-newsletter-challenge-and-giveaway/thank you for your answer and sorry for being misunderstood.
Sophia Gavish
2010-02-27 16:39:33
@Sophia: I think it is just a design decision to make things simpler. For example, if the comments were marked 1,2,3 etc for each post, when you want to reply to a comment, the server side script must translate (post#, comment#) into the unique comment#. If it has the unique comment id as in the database, it's not required.
Chetan Sastry
2010-02-27 17:00:54
+1
A:
If you meant "unique ID in the HTML":
- Every ID in HTML has to be unique.
- Even if there are no links to the separate comments on the page itself, like on the page which you linked to, IDs are still very handy when someone else wants to point to a particular comment from within another page. Like, when I want to point someone to the comment of Jeremy regarding email updates, I can simply do so.
Marcel Korpel
2010-03-01 03:03:57