Récupération du nom du dernier post
Posté : 28 sept. 2014, 11:06
Bonjour à tous,
j'essaie de récupérer le nom de l'auteur du dernier message sur un forum ("auteur" dans la table forum_reponse).
Il y a 4 tables pour se faire. Mais je n'y arrive pas.
Voici ma requête (mais qui ne marche pas bien sûr) :
Je vous laisse les 4 tables
Merci de vos réponses
j'essaie de récupérer le nom de l'auteur du dernier message sur un forum ("auteur" dans la table forum_reponse).
Il y a 4 tables pour se faire. Mais je n'y arrive pas.
Voici ma requête (mais qui ne marche pas bien sûr) :
<?php
$sql_r = ('SELECT fr.auteur, fs.id, m.pseudo, fr.correspondance_sujet, forum_cat.id, fs.id_cat, fs.id FROM membres as m, forum_sujets as fs, forum_cat, forum_reponses as fr WHERE fr.auteur=m.id and fs.id=fr.correspondance_sujet and fs.id_cat=forum_cat.id ');
?>
Si quelqu'un pourrait m'aider.Je vous laisse les 4 tables
Merci de vos réponses
CREATE TABLE IF NOT EXISTS `forum_reponses` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`auteur` int(11) NOT NULL,
`message` text COLLATE latin1_general_ci NOT NULL,
`date_reponse` bigint(25) NOT NULL,
`correspondance_sujet` int(6) NOT NULL,
`cat` int(6) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=347 ;
CREATE TABLE IF NOT EXISTS `forum_cat` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`nom_cat` varchar(30) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=33 ;
CREATE TABLE IF NOT EXISTS `forum_sujets` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`id_cat` int(6) NOT NULL,
`auteur` varchar(30) COLLATE latin1_general_ci NOT NULL,
`titre` text COLLATE latin1_general_ci NOT NULL,
`date_derniere_reponse` bigint(25) NOT NULL,
`date_creation` bigint(25) NOT NULL,
`compteur` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=30 ;
et la dernièreCREATE TABLE IF NOT EXISTS `membres` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pseudo` varchar(40) NOT NULL,
`mot_passe` varchar(255) NOT NULL,
`acces` tinyint(1) NOT NULL DEFAULT '0',
`date_inscription` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`avatar` varchar(255) NOT NULL,
`avatar_actif` smallint(1) NOT NULL,
`admin` tinyint(1) NOT NULL,
`email_visible` smallint(1) NOT NULL,
`design` varchar(255) NOT NULL,
`langue` varchar(255) NOT NULL DEFAULT 'francais',
`sexe` smallint(1) NOT NULL,
`date_naissance` date NOT NULL,
`mail_forum` int(1) NOT NULL DEFAULT '1',
`message_prive` smallint(1) NOT NULL,
`valide` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=106 ;