begin process at 2012 05 28 23:25:47
  Trouver un code source :
 
dans
 
Accueil > Forum > 

PHP

 > 

Divers

 > 

Divers

 > 

Casse tête de conditions !!


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Casse tête de conditions !!

vendredi 27 février 2009 à 10:56:23 | Casse tête de conditions !!

arkonara

bonjour a tous,
alors je vous explique:
j'ai un formulaire de recherche comprenant 4 criteres, j'ai ecrit le script si dessous qui selon traite tous les cas possibles, mais lorsque que je l'execute rien ne s'affiche, voyez vous pkoi?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Liste des incidents</title>
</head>
<body>
<form name="form" action="../Excel.php">
    <table style="text-align: left; width: 100%;" cellpadding="2" cellspacing="2">
    <tr>
        <td style="height: 300px; width: 347px;"><img src="../logo_maif.jpg"></td>
        <td><center><font face="arial" color='#01796F'><h1><b><u>Gestion des incidents éditiques</u></b></h1></center></td>
    </tr>
</table>
<br>
<hr color='#01796F'/>
<hr color='#01796F'/>
<H2><FONT FACE="arial" COLOR='#01796F'><div align="center">Consultation des incidents recherchés</div></FONT></H2>
<hr/ color='#01796F'>
<font face="arial" color='#01796F'><b>Liste des Incidents :</b><br>
<br>
<?php
require_once('../connexion.php');
if ($db)
{
//allocation des variables                                       $dateicdt=$_POST['AnotherDate'];
$majeur=$_POST['choix'];
$matereiel=$_POST['lstMateriel'];
$statuprod=$_POST['lstStatutProd'];
$prestataire=$_POST['lstPrestataire'];


if (dateicdt != "")
{
$date=strftime ('%Y-%m-%d', $dateicdt); //Ici j' obtient une date du type "2009-02-25"
$icdtdate=mysql_query("SELECT * FROM incidents WHERE date_icdt >='$date'");    
if (! $resultat) { echo "Erreur requete"; exit;} //message en cas d'erreure
if (prestataire != "")
{
if (majeur != "")
{
if (matereiel != "")
{
if (statuprod != "")//si dateicdt, prestataire,materiel,statProd ne sont pas vide et que majeur=oui, je fait ma recherche
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")//si dateicdt, prestataire,materiel, ne sont pas vide et que majeur=oui, je fait ma recherche
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND icdt_majeur='$majeur'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
else
{
if (matereiel != "")
{
if (statuprod != "")//si dateicdt, prestataire,materiel,statProd ne sont pas vide et que majeur=non, je fait ma recherche
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")//si dateicdt, prestataire,statProd ne sont pas vide et que majeur=non, je fait ma recherche
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodePrestataire='$prestataire'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
}
else
{
if (majeur != "")
{
if (matereiel != "")
{
if (statuprod != "")//toujours le meme raisonnement juqu'a la fin
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND icdt_majeur='$majeur' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND icdt_majeur='$majeur'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
else
{
if (matereiel != "")
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE date_icdt='$icdtdate'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
}
}
else
{
if (prestataire != "")
{
if (majeur != "")
{
if (matereiel != "")
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND icdt_majeur='$majeur' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND icdt_majeur='$majeur'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
else
{
if (matereiel != "")
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE CodePrestataire='$prestataire'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
}
else
{
if (majeur != "")
{
if (matereiel != "")
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE icdt_majeur='$majeur' AND CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE icdt_majeur='$majeur' AND CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE icdt_majeur='$majeur' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE icdt_majeur='$majeur'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
else
{
if (matereiel != "")
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodeMeteriel='$materiel' AND CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
else
{
$query =("SELECT * FROM incidents WHERE CodeMeteriel='$materiel'");
$result= mysql_query($query) or die(mysql_error());
}
}
else
{
if (statuprod != "")
{
$query =("SELECT * FROM incidents WHERE CodeStatutProd='$statuprod'");
$result= mysql_query($query) or die(mysql_error());
}
}
}
}
}
}
else
{
'Problème à la connexion';
}
?>
<table border="1" align="center"> <!-- tableau permettant de consulter les cellules -->
<tr bgcolor="#01796F">            
    <th><font FACE="arial" COLOR='#FFFFFF'> Numéro de fiche </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Fiche en rapport </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Date </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Heure </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Déclarant </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Majeur </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Impact Sociétaire </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Matériel </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Secteur </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Statut Incident </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Statut Production </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Prestataire </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Description </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Intervenant </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Date de résolution </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Heure de résolution </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Description de la résolution </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Observation </font></th>
<th><font FACE="arial" COLOR='#FFFFFF'> Motif de ré-ouverture </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Numéro TeamTrack </font></th>
    <th><font FACE="arial" COLOR='#FFFFFF'> Remarque du responsable </font></th>
</tr>
<?php
while ($rep = mysql_fetch_assoc($result)) // tant qu'il existe des intervention pour cette afficher, tout afficher
{
    ?>
<tr>      
<td><center><?php echo $rep['num_fiche']; ?></center></td>
<td><center>
<?php
if ($rep['lien_fiche'] == "")
    {
        echo'aucune';
}
else
{
echo $result['lien_fiche'];
    }
?>
</center></td>
<td><center><?php echo $rep['date_icdt']; ?></center></td>
<td><center><?php echo $rep['heure_icdt']; ?></center></td>
<td class="textetab"><center>
<?php
$numemploye = $rep['NumEmploye'];
$resultat6 = mysql_query("SELECT NumEmploye, Nom FROM employer WHERE NumEmploye='$numemploye';");
$result6 = mysql_fetch_assoc($resultat6);
echo $result6['NumEmploye'];
echo $result6['Nom'];
?></center></td>
<td><center>
        <?php
            if ( $rep['icdt_majeur'] == "0" )
            {
                echo'Non';
}
else
        {
        echo'Oui';
}
?></center></td>
<td><center>
        <?php
            if ( $rep['ImpactSocietaire'] == "0" )
            {
                echo'Non';
}
else
        {
        echo'Oui';
}
?></center></td>
<td class="textetab"><center>
<?php
$codemateriel = $rep['CodeMateriel'];
$resultat2 = mysql_query("SELECT Nom FROM materiel WHERE CodeMateriel='$codemateriel';");
$result2 = mysql_fetch_assoc($resultat2);
echo $result2['Nom'];
?></center></td>
<td class="textetab"><center>
<?php
$codesecteur = $rep['CodeSecteur'];
$resultat3 = mysql_query("SELECT Nom FROM secteur WHERE CodeSecteur='$codesecteur';");
$result3 = mysql_fetch_assoc($resultat3);
echo $result3['Nom'];
?></center></td>
<td class="textetab"><center>
<?php
$codestatuincident = $rep['CodeStatutIncident'];
$resultat4 = mysql_query("SELECT Libelle FROM statutincident WHERE CodeStatutIncident='$codestatuincident';");
$result4 = mysql_fetch_assoc($resultat4);
echo $result4['Libelle'];
?></center></td>
        <td class="textetab"><center>
<?php
$codestatutprod = $rep['CodeStatutProd'];
$resultat5 = mysql_query("SELECT Libelle FROM statutprod WHERE CodeStatutProd='$codestatutprod';");
$result5 = mysql_fetch_assoc($resultat5);
echo $result5['Libelle'];
?></center></td>
  
<td class="textetab"><center>
<?php
$codeprestataire = $rep['CodePrestataire'];
$resultat7 = mysql_query("SELECT Nom FROM prestataire WHERE CodePrestataire='$codeprestataire';");
$result7 = mysql_fetch_assoc($resultat7);
echo $result7['Nom'];
?></center></td>
<td><center><?php echo $rep['descrip_icdt']; ?></center></td>
<td><center><?php echo $rep['Intervenant']; ?></center></td>
<td><center><?php echo $rep['date_resol']; ?></center></td>
<td><center>
<?php
    if ( $rep['heure_resol'] == "" )
    {
        echo'non résolu';
    }
    else
    {
        echo $rep['heure_resol'];
    }
?></center></td>
<td><center><?php echo $rep['descrip_resol']; ?></center></td>
<td><center>
<?php
if ( $rep['observation'] == "" )
{
    echo'non renseigner';
}
else
{
    echo $rep['observation'];
    }
?></center></td>
<td><center>
<?php
if ( $rep['motif_r_icdt'] == "" )
{
    echo'pas ré-ouvert';
}
else
{
        echo $rep['motif_r_icdt'];
    }
?></center></td>
<td><center>
<?php
    if ( $rep['num_teamtrack'] == "" )
{
    echo'non renseigner';
}
else
{
    echo $rep['num_teamtrack'];
}
?></center></td>
<td><center>
<?php
if ( $rep['remarque_resp'] == "" )
{
echo'non renseigner';
}
else
{
echo $rep['remarque_resp'];
}
?></center></td>
</tr>
<?php
}
?>
</table>    
<br>
<table style="width: 100%">
<tr>
<td style="width: 50%"><center><a href="../acceuil.php"><font face="arial" color='#01796F' size="2">Retour au menu</a></center></td>
<td><center><input type="submit" name="Excel" value="Exporter sous Excel"></center></td>
</tr>
</table>
</form>
</body>
</html>
vendredi 27 février 2009 à 11:34:42 | Re : Casse tête de conditions !!

Sodams

Membre Club
if (dateicdt != "")
{
}

Attention : Tu oublies les $

if ($dateicdt != "")
{
}
vendredi 27 février 2009 à 11:45:45 | Re : Casse tête de conditions !!

arkonara

ah bien vu sodams, roooo la boulette javai mm po fait gaffe a sa lol ^^ :)
vendredi 27 février 2009 à 13:38:42 | Re : Casse tête de conditions !!

arkonara

en effet cela fonctionne beaucoup mieu excepter pour certains criteres exemple pour le critere prestataire, quelque soit le prestataire que je choisit dans ma liste deroulante il me retourne toujours le mm resultat


Cette discussion est classée dans : mysql, and, query, majeur, incidents


Répondre à ce message

Sujets en rapport avec ce message

Pb MySQL Query [ par kbumbazz ] Salut j'ai un petit pb :MySQL Query Error: INSERT INTO xoops_toto VALUES('','1','1','1','1','1')Error number:0Error message: voila la strucute de ma t echo $idcateg["macolonne"]; [ par fil ] mysql_select_db($database, $perles);$query_idcateg = sprintf("SELECT $mescolonnes FROM $matable WHERE $matable = '%s'", $colname_idcateg);$idcateg = m Erreur dans un script [ par philagui ] Bonjour,est-ce que quelqu'un pourrait me dire où est l'erreur dans ce script:$sql_query="SELECT Titre FROM Tableaux WHERE LIMIT 0,2";//Début de la que Retour à la ligne [ par philagui ] Bonjour,je fais afficher tous les resultats d'un champ d'une DB MySQL par l'intermédiaire du script suivant:$sql="SELECT Titre FROM Tableaux WHERE 1"; galere avec free et php MySQL [ par bigfootspi ] bon voila le code de mon livre d'or !le soucis c'est qu'il met dix ans a se connecter a la base alors que de temps en temps il va vite ! je ne compren Question MySQL [ par mightteam ] j'ai fait mon moteur de recherche mais je voudrais limité le nombre de resultats a afficher par page quel commande dois-je utiliser?ma requète est la Connection avec MS Query (Excel) via ODBC MySQL PC Distant [ par javigle ] Connection avec MS Query (Excel) via ODBC MySQL PC DistantJ'ai un PC (A) ou j'ai la BD et EasyPHP (PHP, Apache, MySQL) enclenché, etsur l'autre PC (B) problème de requête [ par brice57 ] Bonjour, j'ai un problème avec la requête suivante que je ne parviens pas à exécuter sur une base Mysql:$query = "DELETE FROM Defi WHERE Passteam=".$p indexation et défillement [ par toffis ] Bonjour,J'ai un petit probleme avec ce script compte tenu que l'indexation avec LIMIT ne fonctionne pas dans ce cas,je voudrais quand même avoir la po ## Où est l'erreur ???? bon diou !! [ par kodiask ] voila dite moi pourkoi lorsque je met le code la, il n'y a rien ki saffiche ? (c un système de citation aléatoire)mysql_select_db('cit_tbl',$db); $que


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales