Djall |
voilà les news sont stockées ds une table news et les commentaires sont stockés dans une table commentaire ac les champs suivants id (auto incrémenté) id_news pseudo commentaire donc le lien par exemple pour la page permettant de voir les commentaire de news est: viewcomm.php3?id_news=3 donc je récupère l'id des news pour les stocker dans le champ id_news de la table commentaire, mais le problème c'est que j'ai les message d'erreur suivants en voulant afficher la page commentaire vous pouvez aller voir sur http://youpimatin.free.fr
je suis un peu newbie je sais pas trop si il faut exécuter une autre commande pour la requête.
mais merci d'avance pour votre aide.
"Warning: 1 is not a MySQL result index in your script on line 143 Warning: 1 is not a MySQL result index in your script on line 144 Warning: 1 is not a MySQL result index in your script on line 145 Warning: 1 is not a MySQL result index in your script on line 146"
Donc le première requête pour afficher la news concernée ds la page viewcomm <? $db = mysql_connect("sql.free.fr", "base", "pass" ); mysql_select_db("bdedonnee",$db); $req = mysql_query("SELECT * FROM news WHERE id='$id_news'" ); $res = mysql_numrows($req); $titre = mysql_result($req,$i,"titre" ); $newstxt = mysql_result($req,$i,"newstxt" ); $date = mysql_result($req,$i,"date" ); $heure = mysql_result($req,$i,"heure" ); echo "<table width="80%" border="0" cellpadding="0" cellspacing="0">"; echo "<tr>"; echo "<td width="4%"><img src="../images/newstab/topleft.gif" width="20" height="20"></td>"; echo "<td width="93%" background="../images/newstab/fill.gif">"; echo "<div align="left"> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><b><font color="#FFFFFF" size="2"> $date - à $heure Djall</font></b></font></div>"; echo "</td>"; echo "<td width="3%">"; echo "<div align="center"><img src="../images/newstab/topright.gif" width="20"></div>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<table width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="#C80404">"; echo "<tr>"; echo "<td>"; echo "<div align="center">"; echo "<table width="100%" border="0" cellpadding="0" cellspacing="0">"; echo "<tr>"; echo "<td colspan="4">"; echo "<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font color="#C40027">$titre</font></b></div>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td width="7%"> </td>"; echo "<td width="85%" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif">$newstxt</font></td>"; echo "<td colspan="2" width="8%"> </td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo " "; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br>"; $newstxt = stripslashes($newstxt); mysql_close(); echo "<A HREF="javascript:void(0)" onClick="window.open('./addcomm.php3?id_new s=$id_news','commentaires', 9;width=350,height=250');">Ajouter</a>"; ?> et la deuxième pour y afficher les commentaires qui lui sont assiciés <? $db = mysql_connect("sql.free.fr", "base", "pass" ); mysql_select_db("youpimatin",$db); $reqcomm = mysql_query("SELECT * FROM commentaires WHERE id_news='$id_news'" ); $rescomm = mysql_numrows($reqcomm); $i=0; WHILE($rescomm!=$i) { $pseudo = mysql_result($rescomm,$i,"pseudo" ); $commentaire = mysql_result($rescomm,$i,"commentaire" ); $date = mysql_result($rescomm,$i,"date" ); $heure = mysql_result($rescomm,$i,"heure" ); echo "<table width="80%" border="0" cellpadding="0" cellspacing="0">"; echo "<tr>"; echo "<td width="4%"><img src="../images/newstab/topleft.gif" width="20" height="20"></td>"; echo "<td width="93%" background="../images/newstab/fill.gif">"; echo "<div align="left"> <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><b><font color="#FFFFFF" size="2"> $date - à $heure $pseudo</font></b></font></div>"; echo "</td>"; echo "<td width="3%">"; echo "<div align="center"><img src="../images/newstab/topright.gif" width="20"></div>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<table width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="#C80404">"; echo "<tr>"; echo "<td>"; echo "<div align="center">"; echo "<table width="100%" border="0" cellpadding="0" cellspacing="0">"; echo "<tr>"; echo "</tr>"; echo "<tr>"; echo "<td width="7%"> </td>"; echo "<td width="85%" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif">$commentaire</font></td>"; echo "<td colspan="2" width="8%"> </td>"; echo "</tr>"; echo "</table>"; echo "</div>"; echo " "; echo "</td>"; echo "</tr>"; echo "</table>"; echo "<br>"; $commentaire = stripslashes($commentaire); $i++; } mysql_close(); ?> |