在照片中“标记”用户?

I'm trying to code a way for users to "tag" other users in PHP/MySQL.

So far my idea is this:

  • Create a table called "pictures", and a field called "tagged".
  • Store a (serialized?) array in "tagged" which I can pull down with a sql query.

This seems like a really ugly way of handling the task - anyone have any suggestions for me?

If you're looking to do Facebook-style tagging of people in photos (i.e. overlay on top of the photo), try this how-to article:
http://www.bryantan.info/jquery/facebook-like-photo-tagging-using-jquery-and-php/5

If you simply want to have a list of names next to the photo, create a many-to-many linking table. Example:

create table pictures (
    id int auto_increment,
    photo_url varchar(100),
    primary key (id)
);

create table users (
    id int auto_increment,
    photo_url varchar(100),
    primary key (id)
);


create table users_in_photos (
    id int auto_increment,
    photo_id int,
    user_id int,
    primary key (id)
);

Have a table called pictures, a table called tags and a table called pictureTags. Picture tag needs id, pictureid, tagid and depending if you plan to highlight a face on hover, x1, width, y1, height to store the coordinates of the persons face in the image. I recommend a jQuery plugin called jCrop if you plan to store the persons face coordinates, it will allow you to easily grab them.