Au secours probleme variable

Résolu
matmar08120 Messages postés 144 Statut Membre -  
matmar08120 Messages postés 144 Statut Membre -
Bonjour,
voila mon souci:

j'ai fait un while pour lister mes news.
je souhaite les publier, depublier, supprimer ou modifier.
je souhaite obtenir les variables pour effectuer ces actions dessus.

lors de l'envoi du formulaire .
mes conditions du switch fonctionne mais uniquement pour ma derniere variable (ma derniere news affiché dans mon select).J'aimerais obtenir l'identifiant pour chaque news et qu'elle soit transmise car sinon il effectue une condition érroné (modifier à chaque fois)
Merci de votre aide. JE peux etre plus explicite si vous le souhaitez

je vous transmets le code que j'ai effectué pour l'envoi du formulaire
echo '<center><h3>'. ($titre_contenu). '</h3></center><br/> <br /> <br /><center>
<form name="news" method="POST" action="admin_news_choix.php">
<table>
<tr><th align="center">Titre</th>
<th align="center">Rubrique</th>
<th align="center">Etat</th>
<th align="center">Action</th>
</tr>
';

$req_news=mysql_query("SELECT * FROM NEWS ORDER BY Evenement,Id_News DESC ") or die (mysql_error());

while ($news=mysql_fetch_array($req_news))
{

$Etat=$news['Valide'];
$Titre=$news['Titre'];
$Evenement=$news['Evenement'];
$Id=$news['Id_News'];




echo' <tr>
<td align="left">'.$Titre.'</td>
<td align="center" width="100">';
if ($Evenement==1)
{
echo ' Evenement';
}
else if($Evenement==0)
{
echo 'News';
}
echo '</td>
<td align="center" width="100">';
if ($Etat==1)
{
echo ' <img src="../images/visualiser.png"/>';
}
else if($Etat==0)
{
echo '<img src="../images/supprimer.png"/>';
}



echo '<td align="center" width="100"> <select name="choix">
<option value="Modifier">Modifier</option>
<option value="Supprimer">Supprimer</option>
<option value="Publier">Publier</option>
<option value="Depublier">Dépublier</option>
</select></td>


<td> <input type="submit" name="ok" value="OK"/></td>

<input type="hidden" name="news" value="'.$Titre.'"/>
<input type="hidden" name="id_news" value="'.$Id.'"/>
';
}
echo '<tr/> </table></form><br />';

1 réponse

matmar08120 Messages postés 144 Statut Membre 31
 
je suis parvenu à trouver la solution je vous la donne.
J'ai utiliser des GET et j'ai transmis mes variables dans les url... Normal c d GET ....
J'avais privilégier des formulaires, le PROBLEME c qu' il y a donc autant de formulaire que de news. Ce qu'il fait plusieurs fois la même variable.

VOila la solution du code:echo '<center><h3>'. ($titre_contenu). '</h3></center><br/> <br /> <br /><center>
<form name="news" method="POST" action="admin_news_choix.php">
<table>
<tr><th align="center">Titre</th>
<th align="center">Rubrique</th>
<th align="center">Etat</th>
<th align="center">Action</th>
</tr>
';

$req_news=mysql_query("SELECT * FROM NEWS ORDER BY Evenement,Id_News DESC ") or die (mysql_error());

while ($news=mysql_fetch_array($req_news))
{

$Etat=$news['Valide'];
$Titre=$news['Titre'];
$Evenement=$news['Evenement'];
$Id=$news['Id_News'];




echo' <tr>
<td align="left">'.$Titre.'</td>
<td align="center" width="100">';
if ($Evenement==1)
{
echo ' Evenement';
}
else if($Evenement==0)
{
echo 'News';
}
echo '</td>
<td align="center" width="100">';
if ($Etat==1)
{
echo ' <img src="../images/visualiser.png"/>';
}
else if($Etat==0)
{
echo '<img src="../images/supprimer.png"/>';
}


///////////////////////LE CHANGEMENT SE SITUE ICI/////////////////////////////////////

echo '<td align="center">
<a href="admin_news_choix.php?choix=Modifier&id_news='. $Id .'&news='.$Titre.'">Modifier</a>
</td>
<td align="center">
<a href="admin_news_choix.php?choix=Supprimer&id_news='. $Id .'&news='.$Titre.'">Supprimer</a>
</td>
<td align="center">
<a href="admin_news_choix.php?choix=Publier&id_news='. $Id .'&news='.$Titre.'">Publier</a>
</td>
<td align="center">
<a href="admin_news_choix.php?choix=Depublier&id_news='. $Id .'&news='.$Titre.'">Depublier</a>
</td>';
0