Histoire de requete

Eléphant du PHP | 70 Messages

26 févr. 2009, 16:47

Bonjour a tous, je viens faire appel a vos neurones et surtout a votre organisation.

voila mon probleme est le suivant:
les utilisateur de mon appli, peuvent grace a un formulaire php lancer une recherche sur differents critere.
Mon probleme est que les differents criteres peuvent ne pas etre renseigner donc il faut que je lance une requete concernant seulement les criters selectionner.

J'ai un total de 5 criteres, 1 champ texte
3 liste deroulante
2 bouton radio oui et non

quelqu'un peut-il m'aider, moi je m'embrouille dans le suite de if, elseif et else. Et je n'arrive plus a me lire :?
j'utilise wamp5
ps: si ce n'est pas assez clair n'hesiter pas a me poser des questions[/img]
La devise du vrai Geek ==> Plus tu dors moins t'es fort !!

ViPHP
ViPHP | 3607 Messages

26 févr. 2009, 17:14

On va commencer par regarder ce que tu as déjà fait...
Donc on veut voir le code du formulaire et le code de traitement + la structure de ta base de donnée...
On va déjà voir comment tu as commencé ;)

Eléphant du PHP | 70 Messages

26 févr. 2009, 17:30

Je viens de reussir de faire un traitement de if et elseif qui me permet de repondre a mon besoin, seulement pour le moment je l'ai appliker qu'a 3 critere, il faut que je l'applik a 5 criteres

voici pour le moment ce que j'ai fait

mon formulaire
<!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>
		<?php
			//==========================================================================
			// //Code de : BENOIST David
			// Date : Février 2009
			// Objectif : création d'un utilisateur
			// Base : incidents_editiques
			//==========================================================================
			require_once('../connexion.php');
			//=================
			// Initialisation
			//=================
			mysql_select_db($database,$db);			
		?>
		<title>RechercheIncident</title>
		<meta http-equiv="Content-Type" content="text/html" />
		<meta http-equiv="Content-ScriptType" content="text/javascript" />
		<script type="text/javascript">
			//<![CDATA[				
				//pour gerer le calendrier
				var datePickerDivID = "datepicker";
				var iFrameDivID = "datepickeriframe";
				var dayArrayShort = new Array('Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa');
				var dayArrayMed = new Array('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam');
				var dayArrayLong = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
				var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jui', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec');
				var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Juin', 'Juil', 'Aou', 'Sept', 'Oct', 'Nov', 'Dec');
				var monthArrayLong = new Array('Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Decembre');
			 
				// c'est variables définissent la date
				// pour utiliser un format different, il faut  le defaultDateSeparator
				//et les varialbes defaultDateFormat.
				var defaultDateSeparator = "/";
				var defaultDateFormat = "dmy"    // format par defaut
				var dateSeparator = defaultDateSeparator;
				var dateFormat = defaultDateFormat;
				function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
				{
				var targetDateField = document.getElementsByName (dateFieldName).item(0); 
				if (!displayBelowThisObject)
				displayBelowThisObject = targetDateField; 
				dateSeparator = defaultDateSeparator; 
				if (dtFormat)
				dateFormat = dtFormat;
				else
				dateFormat = defaultDateFormat; 
				var x = displayBelowThisObject.offsetLeft;
				var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
				var parent = displayBelowThisObject;
				while (parent.offsetParent) {
				parent = parent.offsetParent;
				x += parent.offsetLeft;
				y += parent.offsetTop ;
				}
				drawDatePicker(targetDateField, x, y);
			}
				function drawDatePicker(targetDateField, x, y)
				{
					var dt = getFieldDate(targetDateField.value ); 
					if (!document.getElementById(datePickerDivID)) {
					var newNode = document.createElement("div");
					newNode.setAttribute("id", datePickerDivID);
					newNode.setAttribute("class", "dpDiv");
					newNode.setAttribute("style", "visibility: hidden;");
					document.body.appendChild(newNode);
				} 
				var pickerDiv = document.getElementById(datePickerDivID);
				pickerDiv.style.position = "absolute";
				pickerDiv.style.left = x + "px";
				pickerDiv.style.top = y + "px";
				pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
				pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
				pickerDiv.style.zIndex = 10000; 
				refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
				}
				function refreshDatePicker(dateFieldName, year, month, day)
				{
					var thisDay = new Date(); 
					if ((month >= 0) && (year > 0)) {
						thisDay = new Date(year, month, 1);
					} else {
						day = thisDay.getDate();
						thisDay.setDate(1);
					} 
					var crlf = "\r\n";
					var TABLE = "<table cols=7 class='dpTable'>" + crlf;
					var xTABLE = "</table>" + crlf;
					var TR = "<tr class='dpTR'>";
					var TR_title = "<tr class='dpTitleTR'>";
					var TR_days = "<tr class='dpDayTR'>";
					var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
					var xTR = "</tr>" + crlf;
					var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
					var TD_title = "<td colspan=5 class='dpTitleTD'>";
					var TD_buttons = "<td class='dpButtonTD'>";
					var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
					var TD_days = "<td class='dpDayTD'>";
					var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
					var xTD = "</td>" + crlf;
					var DIV_title = "<div class='dpTitleText'>";
					var DIV_selected = "<div class='dpDayHighlight'>";
					var xDIV = "</div>"; 
					var html = TABLE; 
					html += TR_title;
					html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "<") + xTD;
					html += TD_title + DIV_title + monthArrayLong[ thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
					html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, ">") + xTD;
					html += xTR; 
					html += TR_days;
					for(i = 0; i < dayArrayShort.length; i++)
					html += TD_days + dayArrayShort[i] + xTD;
					html += xTR; 
					html += TR;
					for (i = 0; i < thisDay.getDay(); i++)
					html += TD + "&nbsp;" + xTD;
					do {
						dayNum = thisDay.getDate();
						TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";	    
						if (dayNum == day)
							html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
						else
							html += TD + TD_onclick + dayNum + xTD;	    
						if (thisDay.getDay() == 6)
							html += xTR + TR;	    
							thisDay.setDate(thisDay.getDate() + 1);
					} while (thisDay.getDate() > 1) 
					if (thisDay.getDay() > 0) {
						for (i = 6; i > thisDay.getDay(); i--)
							html += TD + "&nbsp;" + xTD;
					}
					html += xTR;
					var today = new Date();
					var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[ today.getMonth()] + " " + today.getDate();
					html += TR_todaybutton + TD_todaybutton;
					html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>Ce mois</button> ";
					html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>Fermer</button>";
					html += xTD + xTR; 
					html += xTABLE; 
					document.getElementById(datePickerDivID).innerHTML = html;
					adjustiFrame();
				}
				function getButtonCode(dateFieldName, dateVal, adjust, label)
				{
					var newMonth = (dateVal.getMonth () + adjust) % 12;
					var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
					if (newMonth < 0) {
						newMonth += 12;
						newYear += -1;
					} 
					return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
				}
				function getDateString(dateVal)
				{
					var dayString = "00" + dateVal.getDate();
					var monthString = "00" + (dateVal.getMonth()+1);
					dayString = dayString.substring(dayString.length - 2);
					monthString = monthString.substring(monthString.length - 2); 
					switch (dateFormat) 
					{
						case "dmy" :
							return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
						case "ymd" :
							return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
						case "mdy" :
							default :
							return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
					}
				}
				function getFieldDate(dateString)
				{
					var dateVal;
					var dArray;
					var d, m, y;
					 
					try {
					    dArray = splitDateString(dateString);
					    if (dArray) {
							switch (dateFormat) 
							{
								case "dmy" :
									d = parseInt(dArray[0], 10);
									m = parseInt(dArray[1], 10) - 1;
									y = parseInt(dArray[2], 10);
								break;
									case "ymd" :
									d = parseInt(dArray[2], 10);
									m = parseInt(dArray[1], 10) - 1;
									y = parseInt(dArray[0], 10);
								break;
									case "mdy" :
									default :
									d = parseInt(dArray[1], 10);
									m = parseInt(dArray[0], 10) - 1;
									y = parseInt(dArray[2], 10);
								break;
							}
							dateVal = new Date(y, m, d);
						} else if (dateString) {
							dateVal = new Date(dateString);
						} else {
							dateVal = new Date();
						}
					} catch(e) {
					dateVal = new Date();
					} 
					return dateVal;
				}
				function updateDateField(dateFieldName, dateString)
				{
					var targetDateField = document.getElementsByName (dateFieldName).item(0);
					if (dateString)
					targetDateField.value = dateString;
					var pickerDiv = document.getElementById(datePickerDivID);
					pickerDiv.style.visibility = "hidden";
					pickerDiv.style.display = "none"; 
					adjustiFrame();
					targetDateField.focus(); 
					if ((dateString) && (typeof(datePickerClosed) == "function"))
					datePickerClosed(targetDateField);
				}
			//]]>
		</script>
		<style>
		body {
			font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
			font-size: .8em;
			}
			
		/* the div that holds the date picker calendar */
		.dpDiv {
			}
			
			
		/* the table (within the div) that holds the date picker calendar */
		.dpTable {
			font-family: Tahoma, Arial, Helvetica, sans-serif;
			font-size: 12px;
			text-align: center;
			color: #01796F;
			background-color: #FFFFFF;
			border: 1px solid #AAAAAA;
			}
			
			
		/* a table row that holds date numbers (either blank or 1-31) */
		.dpTR {
			}
			
			
		/* the top table row that holds the month, year, and forward/backward buttons */
		.dpTitleTR {
			}
			
			
		/* the second table row, that holds the names of days of the week (Mo, Tu, We, etc.) */
		.dpDayTR {
			}
			
			
		/* the bottom table row, that has the "This Month" and "Close" buttons */
		.dpTodayButtonTR {
			}
			
			
		/* a table cell that holds a date number (either blank or 1-31) */
		.dpTD {
			border: 1px solid #ece9d8;
			}
			
			
		/* a table cell that holds a highlighted day (usually either today's date or the current date field value) */
		.dpDayHighlightTD {
			background-color: #CCCCCC;
			border: 1px solid #AAAAAA;
			}
			
			
		/* the date number table cell that the mouse pointer is currently over (you can use contrasting colors to make it apparent which cell is being hovered over) */
		.dpTDHover {
			background-color: #aca998;
			border: 1px solid #888888;
			cursor: pointer;
			color: red;
			}
			
			
		/* the table cell that holds the name of the month and the year */
		.dpTitleTD {
			}
			
			
		/* a table cell that holds one of the forward/backward buttons */
		.dpButtonTD {
			}
			
			
		/* the table cell that holds the "This Month" or "Close" button at the bottom */
		.dpTodayButtonTD {
			}
			
			
		/* a table cell that holds the names of days of the week (Mo, Tu, We, etc.) */
		.dpDayTD {
			background-color: #01796F;
			border: 1px solid #AAAAAA;
			color: white;
			}
			
			
		/* additional style information for the text that indicates the month and year */
		.dpTitleText {
			font-size: 12px;
			color: #01796F;
			font-weight: bold;
			}
			
			
		/* additional style information for the cell that holds a highlighted day (usually either today's date or the current date field value) */ 
		.dpDayHighlight {
			color: 4060ff;
			font-weight: bold;
			}
			
			
		/* the forward/backward buttons at the top */
		.dpButton {
			font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
			font-size: 10px;
			color: white;
			background: #01796F;
			font-weight: bold;
			padding: 0px;
			}
			
			
		/* the "This Month" and "Close" buttons at the bottom */
		.dpTodayButton {
			font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
			font-size: 10px;
			color: white;
			background: #01796F;
			font-weight: bold;
			}
		</style>
	</head>
	<body>
		<table style="text-align: left; width: 100%;" cellpadding="2" cellspacing="2">
		    <tbody>
		        <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>
			</tbody>
		</table>
	    <br>
	    <hr/ color='#01796F'>
	    <hr/ color='#01796F'>
		<H2><FONT FACE="arial" COLOR='#01796F'><div align="center">Recherche d'un incident</div></FONT></H2>
		<hr/ color='#01796F'>
		<H4><FONT FACE="arial" COLOR='#01796F'><div align="left"><u>Critères de recherches :</u></div></FONT></H4>
		<br>
		<br>
		<form name="form" method="post" action="rechercherManager.php">
		<table style="width: 100%;" border="1">
				<tr>
					<td><center><font face="arial" color='#01796F'><center><b>Numéro de fiche :</b>
						<SELECT name="liste1" size="1">
							<option value=""></option>
								<?php
									$sql="SELECT Num_fiche FROM incidents ORDER BY Num_fiche ASC";
									$req=mysql_query($sql) or die(mysql_error());
									while($mat = mysql_fetch_array($req))
									{
										echo '<option value="'.$mat['Num_fiche'].'">' . $mat['Num_fiche'] . '</option>';
									}
								?>
						</SELECT></center>
					</td>
					<td><center><font face="arial" color='#01796F'><center><b>Date de l'incident :</b><input name="AnotherDate"> 
					<input type="button" value="selectionner une date" onclick="displayDatePicker('AnotherDate', this, 'dmy', '.');"></center></center></td>
				</tr>
		</table>
		<table style="width: 100%;" border="1">
				<tr>
					<td><font face="arial" color='#01796F'><center><b>Prestataire en cause :</b>
						<SELECT name="liste2" size="1">
							<?php
								$sql="SELECT CodePrestataire, Nom FROM prestataire ORDER BY CodePrestataire DESC";
								$req=mysql_query($sql) or die(mysql_error());
								while($mat = mysql_fetch_array($req))
								{
									echo '<option value="'.$mat['CodePrestataire'].'">' . $mat['Nom'] . '</option>';
								}
							?>
						</SELECT></center>
					</td>
				</tr>
		</table>
		<table style="width: 100%;" border="1">
				<tr>
					<td><font face="arial" color='#01796F'><center><b>Est-ce un incident majeur ?</b>
					<input type="radio" name="choix" value="1"/>Oui<input type="radio" checked="checked" name="choix" value="2"/>Non</center></td>
				</tr>
		</table>
		<table style="width: 100%;" border="1">
				<tr>
					<td><font face="arial" color='#01796F'><center><b>Matériel en cause :</b>
						<SELECT name="liste1" size="1">
							<option value=""></option>
								<?php
									$sql="SELECT CodeMateriel, Nom, Type FROM materiel ORDER BY CodeMateriel ASC";
									$req=mysql_query($sql) or die(mysql_error());
									while($mat = mysql_fetch_array($req))
									{
										echo '<option value="'.$mat['CodeMateriel'].'">' . $mat['Nom'] . ' ' . $mat['Type'] . '</option>';
									}
								?>
						</SELECT></center>
					</td>
				</tr>
		</table>
		<table style="width: 100%;" border="1">
				<tr>
					<td><font face="arial" color='#01796F'><center><b>Statut de la production :</b>
						<SELECT name="liste1" size="1">
							<option value=""></option>
								<?php
									$sql="SELECT CodeStatutProd, Libelle FROM statutprod ORDER BY CodeStatutProd DESC";
									$req=mysql_query($sql) or die(mysql_error());
									while($mat = mysql_fetch_array($req))
									{
										echo '<option value="'.$mat['CodeStatutProd'].'">' . $mat['Libelle'] . '</option>';
									}
								?>
						</SELECT></center>
					</td>
				</tr>
		</table>		
		<br>
		<br>
		<table style="width: 100%;">
			<tbody>
				<tr>
					<td style="text-align: right; width: 50%;"><center><input type="submit" value="Valider"/></center></td>
				</tr>
			</tbody>
		</table>
		</form>
		<br>
		<br>
		<center>
			<a href="../acceuil.php"><font face="arial" color='#01796F' size="2">Retour au menu</a>
		</center>
	</body>
</html>
le numfiche etant un champ "speciale" si je puis dire je m'en occuperais.

ensuite voici ma bdd

Code : Tout sélectionner

-- phpMyAdmin SQL Dump -- version 2.6.4-pl3 -- http://www.phpmyadmin.net -- -- Serveur: localhost -- Généré le : Jeudi 19 Février 2009 à 08:52 -- Version du serveur: 5.0.15 -- Version de PHP: 5.0.5 -- -- Base de données: `incidents_editiques` -- -- -------------------------------------------------------- -- -- Structure de la table `employer` -- CREATE TABLE `employer` ( `NumEmploye` varchar(6) NOT NULL, `Nom` varchar(25) NOT NULL, `Prenom` varchar(25) NOT NULL, `Fonction` varchar(40) NOT NULL, PRIMARY KEY (`NumEmploye`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Contenu de la table `employer` -- INSERT INTO `employer` VALUES ('00001x', 'MIRE', 'Christophe', 'Exploitation éditique'); INSERT INTO `employer` VALUES ('00002x', 'OUVRARD', 'Jacques', 'Opérateur Impression OCE'); INSERT INTO `employer` VALUES ('00003f', 'GEOFFIC', 'Denis', 'Opérateur Impression OCE'); INSERT INTO `employer` VALUES ('00007g', 'BARBAUD', 'Pascal', 'Operateur Mise sous pli'); INSERT INTO `employer` VALUES ('00008d', 'VEYSSEIRE', 'Catherine', 'Opérateur Mise sous pli'); INSERT INTO `employer` VALUES ('00009s', 'SESE', 'Maryse', 'Opérateur Impression OCE'); INSERT INTO `employer` VALUES ('00011x', 'CHAIGNE', 'Alain', 'Exploitation Editique'); INSERT INTO `employer` VALUES ('09042k', 'CROLET', 'Stephane', 'Responsable Développement éditique'); INSERT INTO `employer` VALUES ('11194k', 'LEPINEUX', 'Elise', 'Analyste Programmeur éditique'); INSERT INTO `employer` VALUES ('97186h', 'BENOIST', 'David', 'Stagiaire'); -- -------------------------------------------------------- -- -- Structure de la table `incidents` -- CREATE TABLE `incidents` ( `num_fiche` int(11) NOT NULL auto_increment, `lien_fiche` varchar(2) default NULL, `date_icdt` date NOT NULL, `heure_icdt` varchar(5) NOT NULL, `descrip_icdt` varchar(500) NOT NULL, `descrip_resol` varchar(500) default NULL, `date_resol` date default NULL, `heure_resol` varchar(5) default NULL, `observation` varchar(500) default NULL, `motif_r_icdt` varchar(500) default NULL, `num_teamtrack` varchar(4) default NULL, `remarque_resp` varchar(500) default NULL, `icdt_majeur` tinyint(1) NOT NULL, `CodeMateriel` int(11) NOT NULL, `CodeSecteur` varchar(4) NOT NULL, `CodeStatutIncident` varchar(3) NOT NULL, `CodeStatutProd` varchar(3) NOT NULL, `NumEmploye` varchar(6) NOT NULL, `CodePrestataire` varchar(5) NOT NULL, PRIMARY KEY (`num_fiche`), KEY `fk_Employer` (`NumEmploye`), KEY `fk_Prestataire` (`CodePrestataire`), KEY `fk_Secteur` (`CodeSecteur`), KEY `fk_StatutIncident` (`CodeStatutIncident`), KEY `fk_StatutProd` (`CodeStatutProd`), KEY `fk_Materiel` (`CodeMateriel`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Contenu de la table `incidents` -- INSERT INTO `incidents` VALUES (1, NULL, '2009-02-05', '09h30', 'plus de papiers', 'ajout de papiers', '2009-02-05', NULL, NULL, NULL, NULL, NULL, 0, 1, '0001', 'FER', 'PNO', '00001x', 'INTMA'); INSERT INTO `incidents` VALUES (2, '1', '2009-02-18', '10h30', 'Machine en panne', 'Rebrancher la machine', '2009-02-18', '11h', 'La machine était débranchée', NULL, NULL, 'C''est limite quand même !!', 0, 6, '0003', 'FER', 'PDE', '09042k', 'INTMA'); INSERT INTO `incidents` VALUES (3, NULL, '2009-02-18', '11h15', 'Blablablabla blablablablabla bla blabla blablablablablablablablabla blablabla bla blablablablabla bla ', 'Blablablavbla bla bla bla blablablablabla blabla blablablablabla bla', '2009-02-18', '11h45', 'Blabla bla blablablablabla blablabla blablablablablablabla blablabla blablablabla bla', NULL, NULL, 'Blablablabla blablablabla blablabla blabla blablablablablablablablablablablablablablablabla bla bla bla blablabla ', 1, 29, '0006', 'FER', 'PBL', '00011x', 'EXTOC'); -- -------------------------------------------------------- -- -- Structure de la table `materiel` -- CREATE TABLE `materiel` ( `CodeMateriel` int(11) NOT NULL auto_increment, `Nom` varchar(30) NOT NULL, `Type` varchar(100) NOT NULL, PRIMARY KEY (`CodeMateriel`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ; -- -- Contenu de la table `materiel` -- INSERT INTO `materiel` VALUES (1, 'Xerox 4127', 'Noir et Blanc'); INSERT INTO `materiel` VALUES (2, 'Xerox CP4110', 'Noir et Blanc'); INSERT INTO `materiel` VALUES (3, 'XEROS DC6060', 'Couleur'); INSERT INTO `materiel` VALUES (4, 'XEROX DC6060', 'Noir et Blanc'); INSERT INTO `materiel` VALUES (6, 'Igen 3', 'Couleur'); INSERT INTO `materiel` VALUES (8, 'OCE', '36121'); INSERT INTO `materiel` VALUES (9, 'OCE', '70247'); INSERT INTO `materiel` VALUES (10, 'OCE', '70248'); INSERT INTO `materiel` VALUES (11, 'OCE', '36120'); INSERT INTO `materiel` VALUES (17, 'STRALFORS', 'Séparateur de Job'); INSERT INTO `materiel` VALUES (18, 'METHERNET', 'Serveur Affranchissement'); INSERT INTO `materiel` VALUES (19, 'MOORE', 'Mise sous pli'); INSERT INTO `materiel` VALUES (20, 'NEOPOST', 'Station Affranchissement / Pesé à la volée'); INSERT INTO `materiel` VALUES (21, 'VITESSE C5 1', 'Pitney Bows'); INSERT INTO `materiel` VALUES (22, 'VITESSE C5 2', 'Pitney Bows'); INSERT INTO `materiel` VALUES (23, 'VITESSE C5 3', 'Pitney Bows'); INSERT INTO `materiel` VALUES (24, 'B 1', 'Pitney Bows'); INSERT INTO `materiel` VALUES (25, 'AFS', 'Pitney Bows'); INSERT INTO `materiel` VALUES (26, 'Pitney Bows', 'Bell Howell'); INSERT INTO `materiel` VALUES (27, 'Pitney Bows', 'Trim Winder'); INSERT INTO `materiel` VALUES (28, 'Pitney Bows', 'Trim Star'); INSERT INTO `materiel` VALUES (29, 'Flexi Mailer', 'Mise sous pli'); -- -------------------------------------------------------- -- -- Structure de la table `prestataire` -- CREATE TABLE `prestataire` ( `CodePrestataire` varchar(5) NOT NULL, `Nom` varchar(20) NOT NULL, PRIMARY KEY (`CodePrestataire`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Contenu de la table `prestataire` -- INSERT INTO `prestataire` VALUES ('EXTAL', 'Externe Altima'); INSERT INTO `prestataire` VALUES ('EXTOC', 'Externe OCE'); INSERT INTO `prestataire` VALUES ('EXTSC', 'Externe Secap'); INSERT INTO `prestataire` VALUES ('EXTSO', 'Externe Socram'); INSERT INTO `prestataire` VALUES ('EXTSR', 'Externe Serena'); INSERT INTO `prestataire` VALUES ('EXTXE', 'Externe XEROX'); INSERT INTO `prestataire` VALUES ('INTMA', 'Interne Maif'); INSERT INTO `prestataire` VALUES ('INTPA', 'Interne Parnasse MAI'); -- -------------------------------------------------------- -- -- Structure de la table `secteur` -- CREATE TABLE `secteur` ( `CodeSecteur` varchar(4) NOT NULL, `Nom` varchar(25) NOT NULL, `Description` varchar(70) NOT NULL, PRIMARY KEY (`CodeSecteur`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Contenu de la table `secteur` -- INSERT INTO `secteur` VALUES ('0001', 'Informatique', 'Production Informatique - Système d''information MAIF'); INSERT INTO `secteur` VALUES ('0002', 'Développement Editique', 'Développement du secteur Editique'); INSERT INTO `secteur` VALUES ('0003', 'Affranchissement', 'Application de gestion des affranchissements industriels'); INSERT INTO `secteur` VALUES ('0004', 'Mise sous pli', 'Atelier de mise sous pli automatique ou manuel'); INSERT INTO `secteur` VALUES ('0005', 'Impression Continue', 'Atelier d''Impression Continu'); INSERT INTO `secteur` VALUES ('0006', 'Impression page/page', 'Atelier d''Impression page à page'); INSERT INTO `secteur` VALUES ('0007', 'Exploitation Editique', 'Atelier d''exploitation éditique'); -- -------------------------------------------------------- -- -- Structure de la table `statutincident` -- CREATE TABLE `statutincident` ( `CodeStatutIncident` varchar(3) NOT NULL, `Libelle` varchar(20) NOT NULL, `Description` varchar(60) NOT NULL, `Date` datetime NOT NULL, PRIMARY KEY (`CodeStatutIncident`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Contenu de la table `statutincident` -- INSERT INTO `statutincident` VALUES ('COM', 'Pris en compte', 'L''incident est pris en compte et en cours de résolution', '2009-02-05 14:50:35'); INSERT INTO `statutincident` VALUES ('FER', 'Fermé', 'L''incident est fermé. Incident Résolu', '2009-02-02 10:54:39'); INSERT INTO `statutincident` VALUES ('OUV', 'Ouvert', 'L''incident est répertorié', '2009-02-04 09:53:44'); INSERT INTO `statutincident` VALUES ('ROU', 'Ré-Ouevrt', 'L''incident est ré-ouvert après sa clotûre', '2009-02-05 15:51:10'); -- -------------------------------------------------------- -- -- Structure de la table `statutprod` -- CREATE TABLE `statutprod` ( `CodeStatutProd` varchar(3) NOT NULL, `Libelle` varchar(10) NOT NULL, `Description` varchar(40) NOT NULL, PRIMARY KEY (`CodeStatutProd`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Contenu de la table `statutprod` -- INSERT INTO `statutprod` VALUES ('PBL', 'Bloquée', 'Production Bloquée'); INSERT INTO `statutprod` VALUES ('PDE', 'Dégradée', 'Production dégradée'); INSERT INTO `statutprod` VALUES ('PNO', 'Normale', 'Production normale malgré l''incident'); -- -- Contraintes pour les tables exportées -- -- -- Contraintes pour la table `incidents` -- ALTER TABLE `incidents` ADD CONSTRAINT `fk_Employer` FOREIGN KEY (`NumEmploye`) REFERENCES `employer` (`NumEmploye`), ADD CONSTRAINT `fk_Materiel` FOREIGN KEY (`CodeMateriel`) REFERENCES `materiel` (`CodeMateriel`), ADD CONSTRAINT `fk_Prestataire` FOREIGN KEY (`CodePrestataire`) REFERENCES `prestataire` (`CodePrestataire`), ADD CONSTRAINT `fk_Secteur` FOREIGN KEY (`CodeSecteur`) REFERENCES `secteur` (`CodeSecteur`), ADD CONSTRAINT `fk_StatutIncident` FOREIGN KEY (`CodeStatutIncident`) REFERENCES `statutincident` (`CodeStatutIncident`), ADD CONSTRAINT `fk_StatutProd` FOREIGN KEY (`CodeStatutProd`) REFERENCES `statutprod` (`CodeStatutProd`);

et voici le premier traitement sur 3 critere que j'ai fait ( je le "traduirais" en php apres deja il me faut la logique )

Si dateicdt != " " Alors
Si majeur != " " Alors
Si materiel != " " Alors
Requete comprenant dans le where dateicdt/majeur/materiel;
Sinon
Requete comprenant dans le where dateicdt/majeur;
FinSi
Sinon
Si materiel != " " Alors
Requete comprenant dans le where dateicdt/materiel;
Sinon
Requete comprenant dans le where dateicdt;
FinSi
FinSi
Sinon
Si majeur != " " Alors
Si materiel != " " Alors
Requete comprenant dans le where majeur/materiel;
Sinon
Requete comprenant dans le where majeur;
FinSi
Sinon
Si materiel != " " Alors
Requete comprenant dans le where materiel;
FinSi
FinSi
FinSi

les trois critere que j'ai choisi on donc ete dateicdt, majeur et materiel
desormais il faut que je mette ce raisonnement en place en y ajoutant les eux autres champs

Je suis sur la bonne voie ou y'a t'il une solution plu simple?
La devise du vrai Geek ==> Plus tu dors moins t'es fort !!