en fait j'ai recréer deux table pour reprendre mon projet a zero et partire sur de bonnes bases.
j'avais pas bien saisie. j'ai remodifié mes tables :
table photossnap
CREATE TABLE `photosnap` (
`id` mediumint(75) NOT NULL auto_increment,
`photo` text NOT NULL,
`prenom` varchar(25) NOT NULL default 'Snapi',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
table photosnapcom
CREATE TABLE `photosnapcom` (
`id` mediumint(75),
nom varchar(128) NOT NULL default '',
commentaire text NOT NULL,
PRIMARY KEY (`id`)
);
par contre comment faire la jointure ?
j'affiche mes photos dans un tableau de cette facon : photo-snap.php
<?php
$nb = 3; // Nombre d'affichages souhaités sur une ligne
// requête SQL
$sql = "SELECT * FROM `photosnap` ORDER BY `id` DESC";
// envoie de la requête
$req = mysql_query($sql) or die('<u>Probleme SQL</u> : '.$sql.'<br>'.mysql_error
());
// affichage des résultats avec $nb résultats par ligne
echo'<table>';
$i = 1;
while($resultat = mysql_fetch_array($req)) {
if($i == 1) { echo'<tr>'; }
echo'<td align="center">
<div id="cadresnap">
<img src="../snap/' , $resultat['photo'] , '" /></br>
' , $resultat['prenom'] , '</br>
>/div>
</td>';
$i++;
if($i > $nb) { echo'</tr>'; $i = 1; }
}
echo'</table>';
?>
mon forumaire de saisi de commentaire : photo-snap-com.php
<form action="photo-snap-valide.php" method="post" enctype="multipart/form-data">
<p> </p>
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td><div align="right">Nom </div></td>
<td><input type="text" name="nom" /></td>
</tr>
<tr>
<td>Commentaire</td>
<td><textarea name="commentaire" id="commentaire" maxlength="255"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Valider" /></td>
</tr>
</table>
</form>
ma page de validation du commentaire: photo-snap-valide.php
<?PHP
$sql = "INSERT INTO photosnapcom(id, nom, commentaire)
VALUES('','$nom','$commentaire')";
mysql_query($sql)
or die('Erreur SQL !'.$sql.'
'.mysql_error());
echo 'Votre commentaire a été ajouter.';
mysql_close();
?>