Page 1 sur 1

Tableau couleur ligne pour données

Posté : 25 janv. 2012, 10:31
par MenphisTimrid
Bonjour à tous.

J'ai actuellement un tableau qui est composé de 2 types de valeurs: il y a des actions et des notes dans un seul tableau.
j'aimerais pouvoir mettre la couleur de fond en jaune lorsque c'est une note :mrgreen:

Je cherche depuis plusieurs jours mais sans trouvé la solution...

Pour être plus concret voici mon tableau:
echo " <table  class=\"Tabledonnees\" ><thead><tr>";
	echo "<th>Type action</th>
	<th>Date action</th>	
	<th>Auteur</th>
	<th>Contact</th>
	<th>Téléphone/Mail</th>
	<th>Résultat</th>
	<th>Description de l'action</th>		
	<th>Date rappel</th>
	<th>Réc.</th>				
	<th>Action <br>planifiée</th><th></th><th></th>					
	</tr></thead>";
	$altenative=0; $numligne = 0;	 $vide="vrai"; $c_ligne=""; $c_ligne2="";
	while ($ligne=mysql_fetch_array($resultset)){	
	
	/*if($_REQUEST["LIB_TYP_ACT"]='NOTE')
	{?>
	<td bgcolor='yellow' >
	<?
	}
	else 
	{?>
	<td bgcolor='white' >
	
		<?}*/ 
		
		
	
			

		echo "<tr  valign=top>";	   
		echo "<td >".$ligne["LIB_TYP_ACT"]."</td>"; 
		echo "<td >".datemysql2francais($ligne["DATE_ACT"])."</td>";  
		echo "<td >".$ligne["EMP"]."</td>";   
	 	echo "<td >".$ligne["CON_LOC"]."</td>";  
		echo "<td >".$ligne["MAIL_CON_LOC"]."</td>";  
		echo "<td >".$ligne["LIB_RES"]."</td>";     
		
		echo "<td >".stripslashes($ligne["DESC_ACT"]);
		if ($ligne["REF_ADR_LOC"] != "" && $ligne["REF_ADR_LOC"] != 0 )  echo " <br> <b>Adresse de visite:</b><br>".get_adresse_locataire($ligne["REF_ADR_LOC"]);
		echo "</td>";  	  
		echo "<td >".datemysql2francaiscourt($ligne["DATE_RAPPEL"])."</td>"; 
		echo "<td >";
		  //getACTION_RECURENTE($ligne["FLAG_ALE"]).
		 if ($ligne["FLAG_ALE"] == 1 ) echo "<img src=\"img/green_tick.gif\" border=0>";
		 echo  "</td>"; 
		echo "<td >". get_action_plannifiee($ligne["ACT_PLA"])."</td>"; 
		echo "<td ><a href=\"modi_action.php?onglet=6&NUM_CON=".$NUM_CON."&NUM_ACT=".$ligne["NUM_ACT"]."&NUM_DOS=".$NUM_DOS."\"> <img border=\"0\" src=\"img/b_edit.png\" atl=\"Modi\"></a></td>";	   
		echo "<td>";
		if ($_SESSION['niveau'] == 1) {
		echo "<a href=\"detail_dossier.php?onglet=6&libelle=l&supp_action=oui&NUM_ACT=".$ligne["NUM_ACT"]."&NUM_DOS=".$NUM_DOS."&NUM_CON=".$NUM_CON."\"  onclick=\"return confirmLink(this, 'Confirmez-vous la suppression de l\'\action \<\ ".$ligne["LIB_TYP_ACT"]." \>\ du ".datemysql2francais($ligne["DATE_ACT"])."');\">";	
       echo "<img border=\"0\" src=\"img/b_drop.png\" atl=\"Supp\"\"></a>";      
	   }
	   echo "</td> </tr>";	
	   
	  

	   
	}
	echo " </table>";

Comme vous l'avez vu j'ai tenté de faire quelque chose (mais sans succès) dans la partie que j'ai mis en commentaire


Si ça peut vous aidez voici ma requête sql:
(select  action.REF_ADR_LOC, action.DATE_ACT,action.DESC_ACT,action.FLAG_ALE,type_action.LIB_TYP_ACT,employe.TRG  AS EMP,action.NUM_ACT,action.NUM_DOS,resultat.LIB_RES	,c.NUM_CON,action.DATE_RAPPEL, 
CONCAT(contact_locataire.PRE_CON_LOC,' ',contact_locataire.NOM_CON_LOC) AS CON_LOC, 
CONCAT( action.TEL_CON_LOC, ' ', action.MAIL_CON_LOC) AS MAIL_CON_LOC , ACT_PLA 	
from 	action , contrat c 
LEFT  JOIN 	locataire On locataire.NUM_DOS = action.NUM_DOS
LEFT  JOIN 	resultat ON action.NUM_RES = resultat.NUM_RES
LEFT  JOIN	type_action ON action.ID_TYPE_ACT = type_action.ID_TYPE_ACT
LEFT  JOIN	employe  ON action.MATR_EMP = employe.MATR_EMP
LEFT  JOIN	contact_locataire ON  action.REF_CON_LOC = contact_locataire.REF_CON_LOC
where
  action.NUM_DOS='".$NUM_DOS."'
and c.NUM_DOS = locataire.NUM_DOS 
and c.PRINCIPAL = '1' )

 UNION 
 
 /*Récupération des notes des employés*/
 
(select '0' as REF_ADR_LOC,datecreer as DATE_ACT,note as DESC_ACT ,'1' as FLAG_ALE ,'NOTE' as LIB_TYP_ACT
, employe.TRG  AS EMP,'1' as NUM_ACT ,'NUM_DOS' as NUM_DOS ,''  as LIB_RES ,'1' as NUM_CON ,'1' as DATE_RAPPEL,'' as   CON_LOC,'' as MAIL_CON_LOC,'' as  ACT_PLA 
 from notes n  
JOIN 	employe On n.user_id=employe.MATR_EMP

where NUM_DOS='".$NUM_DOS."'
and employe.MATR_EMP < 100
)

 UNION 
 /*Récupération des notes des clients*/
 
(select '0' as REF_ADR_LOC,datecreer as DATE_ACT,note as DESC_ACT ,'1' as FLAG_ALE ,'NOTE' as LIB_TYP_ACT
   
, concat(contact_client.NOM_CON_CLI,' ' , contact_client.PRE_CON_CLI)   AS EMP,'1' as NUM_ACT ,'NUM_DOS' as NUM_DOS ,''  as LIB_RES ,'1' as NUM_CON ,'1' as DATE_RAPPEL,'' as   CON_LOC,'' as MAIL_CON_LOC,'' as  ACT_PLA 
 from notes n 

JOIN contact_client on n.user_id=contact_client.REF_CON_CLI
where NUM_DOS='".$NUM_DOS."'
and contact_client.REF_CON_CLI >99  
)
 order by DATE_ACT asc 

Merci bien de m'avoir lu et pour votre aide :D

Re: Tableau couleur ligne pour données

Posté : 25 janv. 2012, 10:36
par xTG
T'as le bon point, sauf que ce n'est pas un td mais un tr qu'il faut utiliser à cet endroit. ^^

Re: Tableau couleur ligne pour données

Posté : 25 janv. 2012, 11:06
par MenphisTimrid
effectivement tu as raison

Par contre lorsque je mets <td> je n'ai plus aucune couleur #-o

Re: Tableau couleur ligne pour données

Posté : 25 janv. 2012, 12:02
par xTG
Regardes le code HTML généré pour vérifier qu'il n'y a pas un problème.

Re: Tableau couleur ligne pour données

Posté : 26 janv. 2012, 10:46
par MenphisTimrid
Comment je suis sensé faire ça :oops: ?

Re: Tableau couleur ligne pour données

Posté : 26 janv. 2012, 11:00
par moogli
clic droit sur la page afficher dans le navigateur puis choisir "afficher la source" :mrgreen:

Re: Tableau couleur ligne pour données

Posté : 27 janv. 2012, 10:50
par MenphisTimrid
Oui mais après je constate que j'ai bien

Code : Tout sélectionner

<tr bgcolor='yellow' > <tr valign=top><td >NOTE</td>


quand c'est une note et pas pour le reste, mais rien à l'affichage :(

Merci encore :D

Re: Tableau couleur ligne pour données

Posté : 27 janv. 2012, 16:37
par MenphisTimrid
En fait j'ai compris une partie de mon erreur: il y à deux balises tr du coup la yellow et écrasé :x cependant j'ai réussi à n'en appelé qu'une seule :

Code : Tout sélectionner

<tr background-color=yellow valign=top><td >NOTE</td>
et ça ne fonctionne toujours pas :(

Re: Tableau couleur ligne pour données

Posté : 27 janv. 2012, 18:59
par xTG
background-color est un attribut CSS et non un attribut de la balise tr.

Re: Tableau couleur ligne pour données

Posté : 30 janv. 2012, 11:39
par MenphisTimrid
Effectivement j'ai changé mais ça ne passe toujours pas:

Code : Tout sélectionner

if($_REQUEST["LIB_TYP_ACT"]='NOTE') { echo "<tr bgcolor=yellow "; } else { echo "<tr bgcolor=white "; } echo " valign=top>";
Voici ce que j'ai fait de cette manière je n'ai qu'un seul tr mais ça ne marche toujours pas

Re: Tableau couleur ligne pour données

Posté : 30 janv. 2012, 11:41
par moogli
tu confond égalité et affectation. Le premier se réalisant avec un == (ou ===) le second avec un seul =.

ta condition est toujours vrai (une affectation se vautre rarement).

@+

Re: Tableau couleur ligne pour données

Posté : 01 févr. 2012, 12:57
par MenphisTimrid
j'ai essayé avec "==" et rien ne se passe :(

Re: Tableau couleur ligne pour données

Posté : 01 févr. 2012, 14:57
par moogli
j'ai essayé avec "==" et rien ne se passe :(
c'est pas significatif comme symptome ;)

a tu regarder le code source généré ?

est tu sur de la présence de $_REQUEST["LIB_TYP_ACT"] ? (d'ailleurs pourquoi $_REQUEST ?).

sinon les attribut html devrait être entourés de "

<tr truc="valeur de truc">
dans ton cas
<tr style="background-color: yellow;">
par exemple

fait attention a ce que la couleur de fond des "td" ne soient pas définie sinon effectivement "ça marche pas".

le plus simple serais surement de définir la couleur de fond des td vue qu'elles prennent toute la place dans le tr ;)

@+