$sql = "SELECT * FROM `commentaires` WHERE `id_article` = '". $id_article ."' ORDER BY `id_commentaire` DESC;";
Tu obtiendrais alors la liste des commentaires exclusivement en rapport direct avec un article précis du dernier au premier. En chageant d'article, tu auras un nouvel identifiant d'article, donc la requête ira chercher les commentaires appropriés et tu n'auras plus les précédents.CREATE TABLE com_tbl (
id int NOT NULL auto_increment,
date_verif varchar (20) NOT NULL,
date varchar (20) NOT NULL,
heure varchar (20) NOT NULL,
pseudo varchar (50) NOT NULL,
email varchar(55) NULL,
site varchar (90) NULL,
message text NOT NULL,
PRIMARY KEY (id))$sql = "SELECT message FROM `com_tbl` AS t1, `com_tbl` AS t2 WHERE t1.msg_parent_id = t2.". $id .";";- l'insertion d'un article verra ce champ rester vide (NULL)
- l'insertion d'un commentaire devra voir dans ce champ la clé primaire de l'article;
Pour récupérer les commentaires pour un article, tu vas faire une auto-jointure

CREATE TABLE com_tbl (
id int NOT NULL auto_increment,
msg_parent_id INT NULL;
date_verif varchar (20) NOT NULL,
date varchar (20) NOT NULL,
heure varchar (20) NOT NULL,
pseudo varchar (50) NOT NULL,
email varchar(55) NULL,
site varchar (90) NULL,
message text NOT NULL,
PRIMARY KEY (id))
et pour deux tables c'est le même principe que sur http://phpdebutant.org/article67.phpCode : Tout sélectionner
CREATE TABLE `com_tbl` (
`id` int(11) NOT NULL auto_increment,
`msg_parent_id` int(11) default NULL,
`date_verif` varchar(20) NOT NULL default '',
`date` varchar(20) NOT NULL default '',
`heure` varchar(20) NOT NULL default '',
`pseudo` varchar(50) NOT NULL default '',
`email` varchar(55) default NULL,
`site` varchar(90) default NULL,
`message` text NOT NULL,
PRIMARY KEY (`id`),
KEY `msg_parent_id` (`msg_parent_id`)
);$req = mysql_query("SELECT date,heure,pseudo,email,message from com_tbl Order by date_verif Desc ") or die ("Erreur requête");
et dans ce post tu me dis de faire une auto-jointure comme ceci:
$sql = "SELECT message FROM `com_tbl` AS t1, `com_tbl` AS t2 WHERE t1.msg_parent_id = t2.". $id .";";
Je ne vois pas comment utiliser les deux en même temps.