requêtes modifier et supprimer ?? - PHP - Programmation
Marsh Posté le 14-06-2010 à 09:59:30
les balises <center>, <b>... ne sont plus à la mode non plu
Pour ta question, ben un bouton qui appelle un script qui fera un DELETE sur l'ID concernant la news.
Marsh Posté le 11-06-2010 à 22:47:15
Bonsoir,
Quel requêtes dois je intégrer a mon code, pour pouvoir modifier et supprimer mes news ???
voici le code de la page news.php3
<?php
if(isset($np)) {
$n_debut=($np-1)*5;
}
else {
$n_debut=0;
}
if($auth[2]==4) $sql = "SELECT * FROM $table_news ORDER BY DATE DESC LIMIT ".$n_debut.", 7";
else $sql = "SELECT * FROM $table_news WHERE OK ='1' ORDER BY DATE DESC LIMIT ".$n_debut.", 5";
$resultat = mysql_query ($sql);
while ($news = mysql_fetch_array ($resultat))
{
$id = $news['ID'];
$date = date("j M Y @ H\hi", $news['DATE']);
$idpseudo = $news['IDPSEUDO'];
$titre = $news['TITRE'];
$texte = $news['TEXTE'];
$nb_comm = $news['NBCOMM'];
$nb_hit = $news['NBHIT'];
$ok = $news['OK'];
$sql = "SELECT * FROM $table_membres WHERE ID ='$idpseudo'";
$result = mysql_query ($sql);
$row=MYSQL_FETCH_ARRAY($result);
if($ok==1) {
if ($nb_comm > 1) $comments = 'comments';
else $comments = 'comment';
if ($nb_hit > 1) $hit = 'hits';
else $hit = 'hit';
if($auth[2]==4) $del = " [<a >edite</a>] [<a >del</a>]";
$texte=str_replace("", "<img src=\"images/smilie/smile.gif\" >", $texte);
$texte=str_replace("", "<img src=\"images/smilie/smile_wink.gif\" >", $texte);
$texte=str_replace(">", "<img src=\"images/smilie/smile_mad.gif\" >", $texte);
$texte=str_replace(":o", "<img src=\"images/smilie/smile_redface.gif\" >", $texte);
$texte=str_replace("", "<img src=\"images/smilie/smile_frown.gif\" >", $texte);
$texte=str_replace("8)", "<img src=\"images/smilie/smile_cool.gif\" >", $texte);
$texte=str_replace(":D", "<img src=\"images/smilie/smile_biggrin.gif\" >", $texte);
$texte=str_replace(":p", "<img src=\"images/smilie/smile_tongue.gif\" >", $texte);
$texte=str_replace(":eek:", "<img src=\"images/smilie/smile_eek.gif\" >", $texte);
$texte=str_replace(":confused:", "<img src=\"images/smilie/smile_confused.gif\" >", $texte);
$texte=str_replace(":!:", "<img src=\"images/smilie/icon_!.gif\" >", $texte);
$texte=str_replace(":?:", "<img src=\"images/smilie/icon_interogation.gif\" >", $texte);
$texte=str_replace(":list:", "<img src=\"images/smilie/icon_list.gif\" >", $texte);
$texte=str_replace(":fleche:", "<img src=\"images/smilie/icon_fleche.gif\" >", $texte);
$texte=str_replace(":lampe:", "<img src=\"images/smilie/icon_lampe.gif\" >", $texte);
$texte=str_replace(":+:", "<img src=\"images/smilie/icon_mainplus.gif\" >", $texte);
$texte=str_replace(":-:", "<img src=\"images/smilie/icon_mainmoin.gif\" >", $texte);
$sql2 = "SELECT * FROM $table_ligues WHERE OK ='1' ORDER BY NAME ASC";
$resultat2 = mysql_query($sql2);
while ($ligues2 = mysql_fetch_array($resultat2)) {
$texte=str_replace(" ".$ligues2['NAME'], " <a href='".$ligues2['SITE']."' target=_blank >".$ligues2['NAME']."</a>", $texte);
$texte=str_replace(" ".strtolower($ligues2['NAME']), " <a href='".$ligues2['SITE']."' target=_blank >".$ligues2['NAME']."</a>", $texte);
$texte=str_replace(" ".strtoupper($ligues2['NAME']), " <a href='".$ligues2['SITE']."' target=_blank >".$ligues2['NAME']."</a>", $texte);
}
$sql3 = "SELECT * FROM $table_clans WHERE OK ='1' ORDER BY TAG ASC";
$resultat3 = mysql_query($sql3);
while ($clan3 = mysql_fetch_array($resultat3)) {
$texte=str_replace(" ".$clan3['TAG'], " <a href='".$clan3['SITE']."' target=_blank >".$clan3['TAG']."</a>", $texte);
$texte=str_replace(" ".strtolower($clan3['TAG']), " <a href='".$clan3['SITE']."' target=_blank >".$clan3['TAG']."</a>", $texte);
$texte=str_replace(" ".strtoupper($clan3['TAG']), " <a href='".$clan3['SITE']."' target=_blank >".$clan3['TAG']."</a>", $texte);
}
echo "<div><div class=titre><b><img src=\"images/arrow.gif\" border=\"0\"> $titre</b></div>";
echo "$texte</b></i>";
echo "<p align=\"right\"><a href=mailto:$row[EMAIL]>$row[PSEUDO]</a> - $date - [<a href=javascript:MM_openBrWindow('news_comm.php3?idnews=$id','news','scrollbars=yes,width=330,height=500') >$nb_comm $comments/$nb_hit $hit</a>]$del ";
echo "</div><br>";
}
elseif($ok=='0' && $auth[2]=='4') {
if(strlen($titre)>20) $titre=substr($titre, 0, 20)."...";
echo "<div><b> - $titre</b> <a href=mailto:$row[EMAIL]>$row[PSEUDO]</a> - $date - [<a href=javascript:MM_openBrWindow('news_look.php3?idnews=$id','looknews','scrollbars=yes,width=600,height=420') >voire</a>] [<a href=\"?action=reacnews&idnews=$id\" >réafficher</a>]</div><br>";
}
}
if($auth[2]==4) $sql = "SELECT * FROM $table_news";
else $sql = "SELECT * FROM $table_news WHERE OK ='1'";
$resultat = mysql_query ($sql);
$nb_news = mysql_num_rows($resultat);
$nb_pages=ceil($nb_news/5);
if(!isset($np)) $np=1;
echo "<center>[ ";
for($i=1; $i<=$nb_pages; $i++) {
$nb_affiche=$nb_pages-$i+1;
if($np==$i) echo $nb_affiche." ";
else echo "<a href='?p=news&np=$i' >".$nb_affiche."</a> ";
}
echo "]</center>";
?>
voici le code de la page editnews.php3
<?php
if($auth[2] != 4 && $auth[2] != 3 && $auth[2] != 2 && $auth[2] != 1)
{
$msg="<b>Vous n'avez pas la permission d'accéder à cette section!</b>";
}
if(!empty($msg))
{
echo "<br><center><b>$msg</b></center><br>";
exit();
}
?>
<FORM name="news" method="POST" action="index.php3?p=editnews" enctype="multipart/form-data">
<input type="hidden" name="action" value="addnews">
<TABLE border="0" align="CENTER">
<tr>
<td>Titre: </td>
</tr>
<tr>
<td>
<input type="TEXT" name="titre" size="50" maxlength="50" value="<?php echo $titre; ?>">
</td>
</tr>
<TR>
<TD> Texte:</TD>
</TR>
<TR>
<TD>
<textarea name="texte" cols="75" rows="10" ><?php echo $texte; ?></textarea>
</TD>
</TR>
</TABLE>
<center>
<a href="javascript:smilie('')"><img src="images/smilie/smile.gif" border="0"></a>
<a href="javascript:smilie('')"><img src="images/smilie/smile_wink.gif" border="0"></a>
<a href="javascript:smilie(':p')"><img src="images/smilie/smile_tongue.gif" border="0"></a>
<a href="javascript:smilie(':D')"><img src="images/smilie/smile_biggrin.gif" border="0"></a>
<a href="javascript:smilie('8)')"><img src="images/smilie/smile_cool.gif" border="0"></a>
<a href="javascript:smilie(':o')"><img src="images/smilie/smile_redface.gif" border="0"></a>
<a href="javascript:smilie('')"><img src="images/smilie/smile_frown.gif" border="0"></a>
<a href="javascript:smilie('>')"><img src="images/smilie/smile_mad.gif" border="0"></a>
<a href="javascript:smilie(':eek:')"><img src="images/smilie/smile_eek.gif" border="0"></a>
<a href="javascript:smilie(':confused:')"><img src="images/smilie/smile_confused.gif" border="0"></a>
<a href="javascript:smilie(':!:')"><img src="images/smilie/icon_!.gif" border="0"></a>
<a href="javascript:smilie(':?:')"><img src="images/smilie/icon_interogation.gif" border="0"></a>
<a href="javascript:smilie(':list:')"><img src="images/smilie/icon_list.gif" border="0"></a>
<a href="javascript:smilie(':fleche:')"><img src="images/smilie/icon_fleche.gif" border="0"></a>
<a href="javascript:smilie(':lampe:')"><img src="images/smilie/icon_lampe.gif" border="0"></a>
<a href="javascript:smilie(':+:')"><img src="images/smilie/icon_mainplus.gif" border="0"></a>
<a href="javascript:smilie(':-:')"><img src="images/smilie/icon_mainmoin.gif" border="0"></a>
<br>
<?php if(!empty($err)): ?>
<br><br>
<b><?php echo $err; unset($err); ?></b><BR><BR>
</center>
<?php endif; ?>
<BR>
<CENTER><INPUT type="SUBMIT" value="Ajouter"></CENTER>
</FORM>
Je sais que le php3 n'est plu a la mode, mais je préfère resté sur cette version la.