使用PDO构建表以接受唯一注释

How do I structure my table so it will not accept double "same" comments from the same name for a particular post, while allowing a user to comment with the same comment and name under another post?

$con->query("create table comment(id int(11) not null auto_increment, post_id varchar(20) not null, comment varchar(1000) not null, name varchar(20) not null, date datetime not null, primary key(id))");

You can use UNIQUE KEY to define unique together on id, name and comment. doing this mysql will not allow the same combination to be inserted in the table. try

$con->query("create table comment(id int(11) not null auto_increment, post_id varchar(20) not null, comment varchar(1000) not null, name varchar(20) not null, date datetime not null, primary key(id),UNIQUE KEY `unique_together` (`id`,`name`,`comment`))");

hope it helps :)