Insert user avatar images into comments

Ask about a PHP problem here.
Post Reply
kgdd
Posts: 17
Joined: Fri Nov 04, 2011 2:24 pm

Insert user avatar images into comments

Post by kgdd »

I have a question:

Would it be possible to add a user image with each comment? For instance, if the admin started a new thread and commented on that thread as username Admin in the admin section, then the avatar code would display the admin.png image next to the comment. If anyone other than the admin commented on the post (not in the admin section), it would display a generic avatar image such as guest.png.

Also, how would I go about making the comment_user field unique? It wouldn't let me when I tried to set it as unique in phpmyadmin. I don't want users commenting to be able to put in Admin or any other already registered username..

Please let me know if this doesn't make sense, thanks in advance.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Insert user avatar images into comments

Post by jacek »

Well you could just check the name they enter against the list of registered users ? If it shows up on the list, show an error saying the name is taken already or something.
Image
kgdd
Posts: 17
Joined: Fri Nov 04, 2011 2:24 pm

Re: Insert user avatar images into comments

Post by kgdd »

How about adding an image per comment based on the commentor?
Josh
Posts: 38
Joined: Tue Oct 11, 2011 9:31 pm

Re: Insert user avatar images into comments

Post by Josh »

In my opinion it sounds like you'd be better off making users register a unique username first.

Or if you want it so that people don't have to register you could have a "comments" table where each posts has their own unique id, then a "comments_avatars" or similar table which has the columns "comment_id" and "image_url". So when someone posts with an avatar the avatars url would be inserted into comments_avatars with the post id as "comment_id" then reference them from inside the display page. If the post doesn't have an avatar you could maybe display a default image or something.
Post Reply