Gaoula73  | bonjour, voila j'ai créer un site il y a quelques années et il me reste quelques détails à finir pour la partie admin, afin qu'il sois complétement opérationnel. Mais voila je ne suis pas très calée en php !!
   J'ai une table lien avec pour arguments :
      . Num_lien en clé primaire
      . Libelle_lien
      . Url_lien
      . Num_categorie en clé étrangère provenant de la table categorie_lien
   J'ai une table categorie_lien avec pour arguments :
      . Num_categorie en clé primaire
      . Libelle_categorie
   Voici le code du fichiers Liens_liens.php :
  Code :
 - <?
 - //require("Template/Template.inc.php" );
 - $db = mysql_connect ("localhost", "root", "" ) ;
 - mysql_select_db ("chamandier" ) ;
 - switch ($_POST['action'])
 - {
 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 - case'Voir':
 - 	$T = new Template ("." ) ;
 - 	$T->set_file('input_nouvelles', 'Modeles/Liens_liens.html');
 - 	$T->set_block('input_nouvelles', 'LienBlock', 'LBlock');
 - 	$Sql = "SELECT * FROM lien ORDER BY Libelle_lien " ;
 - 	$Req = mysql_query ($Sql) ;
 - 	while ($Lien = mysql_fetch_array ($Req))
 - 	{
 -   $T->set_var('Num_lien', $Lien['Num_lien']);
 -   $T->set_var('Libelle_lien', $Lien['Libelle_lien']);
 -   $T->parse('LBlock', 'LienBlock', true);
 - 	}
 - 	$Sql = "SELECT * FROM lien WHERE Num_lien='".$_POST['Form_lien']."'" ;
 - 	$Req = mysql_query ($Sql) ;
 - 	$Info = mysql_fetch_array ($Req) ;
 - 	$T->set_var('Libelle', $Info['Libelle_lien']);
 - 	$T->set_var('Message', '');
 - 	$T->set_var('Lien', $Info['Url_lien']);
 - 	$T->set_var('Libelle_categorie', $Info['Num_categorie']);
 - 	$T->set_var('Num', $_POST['Form_lien']);
 - 	$T->pparse('Output', 'input_nouvelles');
 - break ;
 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 - default:
 - 	$T = new Template ("." ) ;
 - 	$T->set_file('input_nouvelles', 'Modeles/Liens_liens.html');
 - 	$T->set_block('input_nouvelles', 'LienBlock', 'LBlock');
 - 	$Sql = "SELECT * FROM lien ORDER BY Libelle_lien" ;
 - 	$Req = mysql_query ($Sql) ;
 - 	while ($Lien = mysql_fetch_array ($Req))
 - 	{
 -   $T->set_var('Num_lien', $Lien['Num_lien']);
 -   $T->set_var('Libelle_lien', $Lien['Libelle_lien']);
 -   $T->parse('LBlock', 'LienBlock', true);
 - 	}
 - 	$T->set_var('Message', '');
 - 	$T->set_var('Libelle', '');
 - 	$T->set_var('Num', '');
 - 	$T->pparse('Output', 'input_nouvelles');
 - break ;
 - }
 - ?>
 
  |  
 
 Ainsi que le code du fichier Liens_liens.html :
  Code :
 - <br>
 - <form action="index.php?page=Liens_liens" method="post">
 - <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
 -   <tr>
 - 	<td height="22" class="menu"><div align="center">
 - 	  <table width="100%" border="0" cellpadding="0" cellspacing="0">
 -   <tr>
 -     <td width="11"><div align="right"><img src="../Images/Demi_arrondi_gauche_bulle.jpg" width="10" height="20"></div></td>
 -     <td background="../Images/Fond_hor_bulle.jpg"><div align="center"><strong>Gérer les  liens de chaque catégorie </strong></div></td>
 -     <td width="10"><img src="../Images/Demi_arrondi_droit_bulle.jpg" width="10" height="20"></td>
 -   </tr>
 - 	  </table>
 - 	</div></td>
 -   </tr>
 -   <tr>
 - 	<td align="center" valign="top" bgcolor="78B1F3"><table width="500" border="0" cellspacing="1" cellpadding="0">
 -   <tr>
 -     <td align="center" valign="top" bgcolor="#FFFFFF"><table width="500" border="0" cellspacing="5" cellpadding="0">
 -   	  <tr>
 -     <td><table width="100%"  border="0" cellspacing="10">
 -                   <tr>
 -                     <td width="42%">Liste des liens : </td>
 -                     <td width="58%"><select name="Form_lien" size="10" id="Form_lien">
 -                       <!-- BEGIN LienBlock -->
 -     	  <option value="{Num_lien}">{Libelle_lien}</option>
 -     	  <!-- END LienBlock -->
 -                     </select></td>
 -                   </tr>
 -                   <tr>
 -                     <td><input name="Num" type="hidden" id="Num" value="{Num}">
 -                       </td>
 -                     <td><input name="action" type="submit" id="action" value="Voir">
 -                       <input name="action" type="submit" id="action" value="Supprimer"></td>
 -                   </tr>
 -                   <tr>
 -                     <td>Libellé du lien: </td>
 -                     <td><input name="Form_libelle" type="text" id="Form_libelle" value="{Libelle}" maxlength="20"></td>
 -                   </tr>
 -       <tr>
 -                     <td>Url du Lien : </td>
 -                     <td><input name="Form_url" type="text" id="Form_url" value="{Lien}" size="40" maxlength="100"></td>
 -                   </tr>
 -                   <tr>
 -                     <td>Catégorie du Lien : </td>
 -                     <td width="58%"><select name="Form_categorie" size="10" id="Form_categorie">
 -                       <!-- BEGIN CategorieBlock -->
 -     	  <option value="{Num_categorie}">{Libelle_categorie}</option>
 -     	  <!-- END CategorieBlock -->
 -                     </select></td>
 -                   </tr>
 -                   <tr>
 -                     <td><div style="color:#FF0000">{Message}</div></td>
 -                     <td><input name="action" type="submit" id="action" value="Ajouter">
 -                     <input name="action" type="submit" id="action" value="Modifier"></td>
 -                   </tr>
 -                 </table></td>
 -   	  </tr>
 -     </table></td>
 -   </tr>
 - 	</table></td>
 -   </tr>
 - </table>
 - </form>
 - <br>
 
  |  
 
   Je souhaiterais (pour le fichiers Liens_liens.html) que dan sla catégorie du lien, ça m'affiche Libelle_categorie au lieu du numéro. Mais je vois pas comment faire.
   pouvez vous me donner un coup de main?    Message édité par Gaoula73 le 21-11-2006 à 19:27:24
  |