case à cocher

ViPHP
ViPHP | 3607 Messages

17 mai 2006, 15:11

bpn ben j'ai plus qu'a aller me coucher ... :oops:
j'ai honte, je devrait plus poster cet aprem à dans trois semaine (je vais faire une cure de repos)

Avatar du membre
ViPHP
ViPHP | 3008 Messages

17 mai 2006, 15:14

bpn ben j'ai plus qu'a aller me coucher ... :oops:
j'ai honte, je devrait plus poster cet aprem à dans trois semaine (je vais faire une cure de repos)
Et avec 50 cures de vitamines A, B, C, D et F s'il te plaît ! :langue:

Tu nous reviendrais plus en forme hihi

Eléphant du PHP | 94 Messages

17 mai 2006, 15:28

Bon j'ai revu mon code pour dissocier l'html.
J'ai juste une question pour charabia

avant, je faisais appelle à une variable qui correspondait au mode
	  		   	. "<td><a href='_admin.php?mode=". MAJ
	  		   	. "&id=$idURL'><img hspace='2' width='16' height='16'src='./images/b_edit.png' alt='Modifier' title='Modifier' border='0'></a>\n"
Dans ton code, tu as transformé cette ligne en

Code : Tout sélectionner

<td><a href="_admin.php?mode=MAJ&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title='Modifier" border="0"></a></td>
Faut il que je remplace MAJ par <?php . MAJ ?> ? En fait j'ai essayé et plus rien ne fonctionne

EDIT : désolé ... j'ai trouvé :roll: :

Code : Tout sélectionner

<td><a href="_admin.php?mode=<?php echo MAJ?>&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title='Modifier" border="0"></a></td>
rspir

Avatar du membre
ViPHP
ViPHP | 3008 Messages

17 mai 2006, 15:32

A quoi correspond ton
<?php echo MAJ?>
? Ce n'est pas une variable puisqu'il n'y a pas de $ devant...

En fait ton code
<td><a href="_admin.php?mode=<?php echo MAJ?>&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title='Modifier" border="0"></a></td>
reviendrait exactement à ce que j'ai mis à savoir :
<td><a href="_admin.php?mode=MAJ&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title='Modifier" border="0"></a></td>

Eléphant du PHP | 94 Messages

17 mai 2006, 15:40

En fait c'est peut être inutile, mais je fais un incude d'un fichier contenant ceci :
define ("DEFAUT","defaut");

define ("ARC","archive");
define ("INSERT","insertion");
define ("MAJ","maj");
define ("DEL","delete");

define ("LISTCOM","list_com");
define ("LISTARC","list_arc");
Donc je récupère bien ma variable.
Comme dit plus haut, j'ai commencé mon site avec un bouquin, et je me suis inspiré de la méthode décrite. Progressivement j'adapte le code (et j'apprends le PHP) et je nettoie et j'optimise mes fichiers et fonctions.

je pars de loin ... ou plutot de 0.

Ma fonction actuelle donne ceci :
function Tableau ($connexion)
{
	$requete = "SELECT id, dcrea, texte, DATE_FORMAT(dcrea, '%d/%m/%y %H:%i') AS 'dcreation',DATE_FORMAT(MAJ, '%d/%m/%y %H:%i') AS 'dmaj' "
				. " FROM filinfo"
				. " LEFT JOIN refinfo ON filinfo.id = refinfo.idinf"
				. " ORDER BY dcrea DESC";
				
	$resultat = ExecRequete ($requete, $connexion);
	$num=mysql_num_rows ($resultat);
	
	if ($num < 1)
	{
		echo "Aucun <span class='i'>i-</span>communiqué publié<br>\n";
	}
	else
	{
		
		echo "<h1>" .$num. ($num ==1 ? ' <span class="i">i-</span>communiqué publié' : ' <span class="i">i-</span>communiqués publiés') ."</h1>";
//		. "<center><table border=0 cellspacing=2 cellpadding=2>"
//		. "<caption align=bottom>Gestion des <span class='i'>i-</span>communiqués</caption>"
//		. "<tr class='titre'><th>Info<th>Création<th>Modif.<th>ref<th colspan='3'>Action</tr>\n";
		
		$i=0;
		while ($info = ObjetSuivant($resultat))
		{
			$i++;
			$idURL=urlEncode ($info->id);
		?>		
			<tr class="A<?php echo ($i%2);?>" onMouseOver="this.className='over'" onMouseOut="this.className='A<?php echo ($i%2);?>'">

    <td width=450><?php echo $info->texte;?></td>
    <td><?php echo $info->dcreation;?></td>
    <td><?php echo $info->dmaj;?></td>
    <td><input type="checkbox" name="ref[]" value="rae"<?php if($toto=="1") {echo " checked='checked'" ;}?>"/>
    <td><a href="_admin.php?mode=<?php echo MAJ?>&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title='Modifier" border="0"></a></td>
    <td><a href='_admin.php?mode=<?php echo ARC?>&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_tblexport.png" alt="Archiver" title="Archiver" border='0'></a></td>
    <td><a href='_admin.php?mode=<?php echo DEL?>&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_drop.png" alt="Supprimer" title="Supprimer" border='0'></a></td>

   
   

		<?
		}
	
		echo "</table></center>\n";
	}
}
J'ai encore du boulot ...
rspir

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 10684 Messages

17 mai 2006, 15:40

A quoi correspond ton
<?php echo MAJ?>
? Ce n'est pas une variable puisqu'il n'y a pas de $ devant...
C'est pitetre une constante ? s'il a un define("MAJ", 8732) parce que dans son appli les mises à jour sont qualifiées du code 8732, faut qu'il fasse comme il à dit :)

Sinon effectivement, ca sert pas à grand chose :)

Eléphant du PHP | 94 Messages

17 mai 2006, 15:50

Je confirme que cela ne sert pas à grand chose ... à part à m'apprendre à me servir des constante.

Le code corrigé (il trainait encore des coquilles entre simple et double quote)
donne ceci :
<?php 
function Tableau ($connexion)
{
	$requete = "SELECT id, dcrea, texte, DATE_FORMAT(dcrea, '%d/%m/%y %H:%i') AS 'dcreation',DATE_FORMAT(MAJ, '%d/%m/%y %H:%i') AS 'dmaj' "
				. " FROM filinfo"
				. " LEFT JOIN refinfo ON filinfo.id = refinfo.idinf"
				. " ORDER BY dcrea DESC";
				
	$resultat = ExecRequete ($requete, $connexion);
	$num=mysql_num_rows ($resultat);
	
	if ($num < 1)
	{
		echo "Aucun <span class='i'>i-</span>communiqué publié<br>\n";
	}
	else
	{
		
		echo "<h1>" .$num. ($num ==1 ? ' <span class="i">i-</span>communiqué publié' : ' <span class="i">i-</span>communiqués publiés') ."</h1>"
		. "<center><table border=0 cellspacing=2 cellpadding=2>"
		. "<caption align=bottom>Gestion des <span class='i'>i-</span>communiqués</caption>"
		. "<tr class='titre'><th>Info<th>Création<th>Modif.<th>ref<th colspan='3'>Action</tr>\n";
		
		$i=0;
		while ($info = ObjetSuivant($resultat))
		{
			$i++;
			$idURL=urlEncode ($info->id);
		?>		
			<tr class="A<?php echo ($i%2);?>" onMouseOver="this.className='over'" onMouseOut="this.className='A<?php echo ($i%2);?>'">
			
				<td width=450><?php echo $info->texte;?></td>
				<td><?php echo $info->dcreation;?></td>
				<td><?php echo $info->dmaj;?></td>
				<td><input type="checkbox" name="ref[]" value="rae"<?php if($toto=="1") {echo " checked='checked'" ;}?>"/>				
				<td><a href="_admin.php?mode=maj&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_edit.png" alt="Modifier" title="Modifier" border="0"></a></td>
				<td><a href="_admin.php?mode=archive&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_tblexport.png" alt="Archiver" title="Archiver" border='0'></a></td>
				<td><a href="_admin.php?mode=delete&id=<?php echo $idURL;?>"><img hspace="2" width="16" height="16" src="./images/b_drop.png" alt="Supprimer" title="Supprimer" border='0'></a></td>

			</tr>
		<?
		}
	
		echo "</table></center>\n";
	}
}

?>
Reste à supprimer le $toto et à récupérer les "vraies" variables.
rspir