Aller au contenu

sfc2000

Membre
  • Compteur de contenus

    2
  • Inscrit(e) le

  • Dernière visite

Réputation sur la communauté

0 Neutre
  1. merci pour l'aide, ca marche
  2. Bonjour, voilà j'ai un script de news et j'aurais aimé que les visiteurs puissent posté leurs commentaire. Mon problème est que j'ai dans ma table 4 champ a renter: id idArticle pseudo commentaire Ou ca se corse, c'est que je voudrais que mon champ "idArticle" soit rempli automatiquement, plus précisement je voudrais qu'il soit rempli par la même données que l'id de ma news et c'est la le problème impossible de trouver la soluce Quelq'un pourrais m'aider please? Voici mon code: <?php require_once('../Connections/adminConnection.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO commentaire (id, idArticle, pseudo, commentaires) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['idArticle'], "int"), GetSQLValueString($_POST['pseudo'], "text"), GetSQLValueString($_POST['commentaires'], "text")); mysql_select_db($database_adminConnection, $adminConnection); $Result1 = mysql_query($insertSQL, $adminConnection) or die(mysql_error()); } mysql_select_db($database_adminConnection, $adminConnection); $query_ajoutCom = "SELECT * FROM commentaire"; $ajoutCom = mysql_query($query_ajoutCom, $adminConnection) or die(mysql_error()); $row_ajoutCom = mysql_fetch_assoc($ajoutCom); $totalRows_ajoutCom = mysql_num_rows($ajoutCom); $idArticle = ".$ida."; ?><link href="includes/site.css" rel="stylesheet" type="text/css" /> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="660000"><div align="center" class="texteBlanc">News</div></td> </tr> <tr> <td height="10"></td> </tr> <tr> <td><?php include ("admin/connexion2.php"); $req_artCom = "SELECT * FROM articles WHERE idArticle=".$ida; $result_artCom = mysql_query ($req_artCom); $artCom =mysql_fetch_object($result_artCom); mysql_free_result($result_artCom); print("<p class='texte'><font color='ff0000'><b>$artCom->date</b></font><br></p>"); print("<p class='titre'><b>$artCom->titreArticle</font></b><br>$date</p>"); print("<p class='texte' align='justify'>$artCom->texteArticle</p>"); echo "<tr><td height='10' bgcolor='ffffff'></td></tr>"; echo "<tr><td height='10' bgcolor='ffffff'></td></tr>"; echo "<tr><td class='texte' align='center'><b>Les commentaires :</b></td></tr>"; echo "<tr><td height='10' bgcolor='ffffff'></td></tr>"; $requete = "SELECT * FROM commentaire WHERE idArticle=".$ida.""; $resultat = mysql_query ($requete); while ($commentaire =mysql_fetch_object($resultat)) { echo "<tr><td class='texte'><b>$commentaire->pseudo :</b> $commentaire->commentaires</td></tr>"; echo "<tr><td height='5' bgcolor='ffffff'></td></tr>"; echo "<tr><td height='1' bgcolor='660000'></td></tr>"; } ?></td> </tr> <tr> <td height="10"></td> </tr> </table> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Pseudo:</td> <td><input type="text" name="pseudo" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Commentaires:</td> <td><input type="text" name="commentaires" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insérer l'enregistrement"></td> </tr> </table> <input type="hidden" name="id" value=""> <input type="hidden" name="idArticle" value="<?php echo $_GET['idArticle']; ?>"> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> <?php mysql_free_result($ajoutCom); ?>
×
×
  • Créer...