Eléphant du PHP |
96 Messages
23 mai 2006, 15:38
Bon ça se complique !
Voici mon code...pas trop long j'espère.
<?php
//affichage de l'en-tete du tableau ?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr bgcolor="#e9ea6c">
<td align="center" bgcolor="#FFCC66"><span class="Style3">Action</span></td>
<td align="center" bgcolor="#FFCC66"><span class="Style3">Co.</span></td>
<td align="center"><span class="Style3">Client</span></td>
<td align="center"><span class="Style3">Date</span></td>
<td align="center"><span class="Style3">Commune</span></td>
<td align="center" bgcolor="#FFCC66"><span class="Style3">Infos</span></td>
<td align="center"><span class="Style3">Adresse</span></td>
<td align="center"><span class="Style3">Modéle</span></td>
<td align="center"><span class="Style3">Surface</span></td>
<td align="center"><span class="Style3">Annexe</span></td>
<td align="center"><span class="Style3">Fondations</span></td>
</tr>
<tr>
<?php
//$color=alternance des 2 couleurs
$color = 0;
while ($vente=mysql_fetch_array($result))
{
echo '<tr>';
//affiche les 2 couleurs du tableau
$color % 2 ? $bgcolor = "#ddf0a7" : $bgcolor = "#bcdd95";
//affiche l'icone modifier et affiche le nom du client au survol du lien
//et appelle la page modifier.php
echo '<td bgcolor='.$bgcolor.' align="center">';?><span class="Style8">
<?php
/*if (isset($_POST['admin']))
{*/
if ($_COOKIE['admin']=="ok")
{
$lien5="index.php?liste=modifier&vente=".$vente['id_vente'];
afficher_url($lien5,"<img src=\"images/modif.gif\" width=\"21\" height=\"21\" border=\"0\"alt=\" Modifier la fiche de Mr ".$vente[1]." \">");
}
/*}
else {
echo "<img src=\"images/modif.gif\" width=\"21\" height=\"21\" border=\"0\" alt=\" Vous ne pouvez pas modifier ce client \">";
}*/
?>
</span></td>
<?php
//Affichage du nom et des ventes du commercial au survol de la souris
//et appelle la page commercial_choisi.php
echo '<td bgcolor='.$bgcolor.' align="center">';?><span class="Style8">
<?php
$com=$vente['idcommercial'];
$req_commer=mysql_query("select * from commercial where id_commercial='$com'");
$commer=mysql_fetch_array($req_commer);
$lien="index.php?liste=commercial_choisi&choix=commercial&com_choisi=".$commer['id_commercial'];
afficher_url($lien,"<img src=\"images/com.gif\" width=\"21\" height=\"21\" border=\"0\"alt=\" Voir les ventes de ".$commer['commercial']." \">");?>
</span></td>
<?php
//affichage du nom du client, au survol du lien, affichage des notes personnelles et au clic affiche la fiche client
$notes = str_replace ("'", "%",$vente['notes']);
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style4">
<?php
//fiche_client appelle la page fiche_client.php
$lien="index.php?liste=fiche_client&vente=".$vente['id_vente'];?>
<strong><?php echo ('<a href="'.$lien.'" target="_top" title="'.$notes.'">'.$vente[1].'</a>');?></strong>
</span></td>
<?php
//affiche la date de la vente
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<p><a title="<?php echo $vente['date'];?>"><?php echo $vente['date'];?></a></p>
</span></td>
<?php
//affiche la commune et le lien pour voir ttes les ventes de cette commune
//commune_choisie appelle la page commune_choisie.php
// la ligne ci-dessous echappe les "'" qui créent des erreurs dans l'affichage des mots !
$commune = str_replace ("'", "%",$vente['commune']);
$req = mysql_query("select * from vente where commune LIKE '$commune'");
$resultats = mysql_num_rows($req);
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<?php $lien="index.php?liste=commune_choisie&choix=commune&ville_choisi=".$vente['commune'];
{
echo ('<a href="'.$lien.'" target="_top" title=" Il y a '.$resultats.' construction(s) à '.$vente['commune'].' ">'.$vente ['commune'].'</a>');
}?>
</span></td>
<?php
//info sur les mairies et DDE qui appelle la page info_mairie.php
echo '<td bgcolor='.$bgcolor.' align="center">';?>
<?php
//attention la requéte est un peu particuliére (LEFT JOIN)
$sql="SELECT DISTINCT v.commune, i.mairie from vente v LEFT JOIN mairies_info i on v.commune = i.mairie where commune LIKE '%".$commune."%'";
$req = mysql_query($sql);
//echo $sql; validez pour tester la requéte
while($resultats = mysql_fetch_array($req))
{
//"IF" s'il y a des trous dans le champ "mairie" on affiche une icone rouge
//et un lien pour entrer des infos sur la mairie
if($resultats ['mairie'] == "")
{
$lien="index.php?liste=ajout_mairie&choix&ville_choisi=".$vente['commune'];
afficher_url($lien,"<img src=\"images/pas_mairie.gif\" width=\"21\" height=\"21\" border=\"0\"alt=\" Ajouter des infos sur la mairie de ".$vente['commune']." ? \">");
}
else
//"ELSE" sinon le champ "mairie" est rempli, on affiche une icone verte
//et un lien pour voir les infos sur la mairie
{
$lien="index.php?liste=info_mairie&choix&ville_choisi=".$vente['commune'];
afficher_url($lien,"<img src=\"images/ok_mairie.gif\" width=\"16\" height=\"16\" border=\"0\"alt=\" Voir les infos sur la mairie de ".$vente['commune']." ? \">");
}
}
echo "</td>";
//affiche l'adresse de construction
echo '<td bgcolor='.$bgcolor.' align=\"center\">';?><span class="Style8">
<p><a title=" Adresse du lotissement ou diffus "><?php echo $vente['adresse'];?></a></p>
</span></td>
<?php
//recherche le nom du modéle catalogue à partir de son id et le lien pour voir
//toutes les ventes de ce modele
//modele_choisi appelle la page modele_choisi.php
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<?php
$req = mysql_query("select * from vente where idcategorie='".$vente['idcategorie']."'");
$resultats = mysql_num_rows($req);
$catego=$vente['idcategorie'];
$req_cat=mysql_query("select * from categorie where id_categorie='".$catego."'");
$cat=mysql_fetch_array($req_cat);
$lien="index.php?liste=modele_choisi&choix=categorie&cat_choisi=".$cat['id_categorie'];
{
echo ('<a href="'.$lien.'" target="_top" title=" Il y a '.$resultats.' construction(s) de type '.$cat['categorie'].' ">'.$cat['categorie'].'</a>');
}
mysql_free_result ($req_cat);?>
</span></td>
<?php
//surface du modele vendu
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<p><a title=" Surface du modéle "><?php echo $vente['surface'];?> m²</a></p>
</span></td>
<?php
//affiche le type d'annexe et toiture du modele vendu
$annex=$vente['idannexe'];
$req_an=mysql_query("select * from annexe where id_annexe='".$annex."'");
$an=mysql_fetch_array($req_an);
$toi=$vente['idtoiture'];
$req_toit = mysql_query("select * from toiture where id_toiture='".$toi."' GROUP BY `toiture` DESC ");
$toit = mysql_fetch_array($req_toit);
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<a title=" Toiture <?php echo $toit['toiture']; ?> "><?php echo $an['annexe'];?></a></span></td>
<?php mysql_free_result ($req_an);
mysql_free_result ($req_toit);
//affiche le type de fondations, la profondeur et le geotechnicien
$geo=$vente['idgeotechnicien'];
$req_geo = mysql_query("select * from geotechnicien where id_geotechnicien='".$geo."'");
$geotech = mysql_fetch_array($req_geo);
echo '<td bgcolor='.$bgcolor.'>';?><span class="Style8">
<p><a title=" <?php echo $geotech['geotechnicien']; ?> "><?php echo $vente['profondeur'];?> m</a></p>
</span></td>
<?php mysql_free_result ($req_geo);?>
<?php $color++;
echo "</tr>";
}?>
</p></td>
</tr>
</table>
<?php
// on libère l'espace mémoire alloué pour cette requête
mysql_free_result ($result);?>
</table>
</tr>
Et voilà ! comment faire pour rayer toutes les infos du client qui n'est plus actif ?