Log in

View Full Version : most efficient comment box logic



baconDelta
01-17-2012, 01:22 AM
i've been thinking about making a comment box for some images on my site. images can be uploaded, so a template is used in the creation of the page for the image. under the image i want to have a little comment section.

i've scoured around a bit and found some comment box generators and i've also found code to make a 'guestbook' style comment box that uses mysql.

but i'm wondering, if i have say a 100 pictures uploaded per day, or let's say 1000 for example, won't this be a lot of work for my db? serving up all these comments for all these pages everytime a page is requested?

i thought maybe i can store the actual text of the comment on the html page itself, and assign the text a unique id, and just store that in a db, with some info about the user, rather than the text itself. i figure this way the db does a lot less work, since the comments are static rather than served up with each request, and comments can still be tracked.

does this idea make sense? or am i talking crazy? this would be significantly more efficient right?

the thing is i haven't found any generators for storing the text of the comment on the html page, and the ones i have found have to be purchased and look pretty complex in the code.

i guess the task that i'm thinking will be the hardest is getting the comment to be inserted into the page the comment box is on.

can anyone pitch me a few functions i can research to get the ball rolling? is there a function that can be used to insert a variable in a specific spot within an html page without a placeholder? i mean i could use a placeholder i guess, but i'll have to learn how to append new comments on top of older ones, otherwise the placeholder will be filled with one comment, and the next time a comment is submitted there won't be a placeholder.

perhaps there's a function to insert just after the placeholder? so that the placeholder isn't overwritten itself? i'm just trying to figure out what i should research for this :confused::confused::confused:

baconDelta
01-17-2012, 07:07 AM
alright so after a little bit more thought i think it's possible to make a function that will insert text after a placeholder, rather than replacing the placeholder itself. i shall attempt this noble feat!

the other stuff like assigning a unique id to each comment and storing them i can imagine how to do. that stuff is peanuts.

EDIT: after some more research static comments is a very silly idea. i'm storing the comments in a database.