Bonjour à tous!!!
J'ai réalisé un moteur de recherche pour gérer un parc micro!!
Ca fonctionne mais je trouve que mon code est bizarre( en fait je pense que j'ai bidouilé pour réussir )
C'est par rapport aux tests que je fais pour savoir si un champ du formulaire est vide.
Et donc je voulais savoir si c'est correct où y a t-il une méthode plus simple et surtout logique!!( je suis débutant , ne vous moquez pas de moi si c'est du n'importe quoi!!!
MERCI!!!!!
voici le code :
<?mysql_connect("localhost","root","");
mysql_selectdb("intranet");
$nom="Nom_micro";
$user="User";
$bureau="Bureau";
$typemicro="Type_micro";
$PDS="P_D_S";
$mp="mP";
$mhz="MHZ";
$ram="RAM";
$typeram="Type_RAM";
$hdgo="HD_GO";
$serie="Serie";
$achat="Achat";
$fingarantie="Fin_Garantie";
$os="OS";
$office="Office";
?>
<form Method="post" >
<fieldset>
<legend>Recherche avancée : </legend>
<label>Nom micro : <input type="text" name="Nom_micro" /></label><br/>
<label>User : <input type="text" name="User" /></label><br/>
<label>Bureau : <input type="text" name="Bureau"/></label><br/>
<label>Type micro : <input type="text" name="Type_micro" /></label><br/>
<label>P_D_S : <input type="text" name="P_D_S"/></label><br/>
<label>µP : <input type="text" name="mP"/></label><br/>
<label>MHZ : <input type="text" name="MHZ" /></label><br/>
<label>RAM : <input type="text" name="RAM" /></label><br/>
<label>Type_RAM : <input type="text" name="Type_RAM" /></label><br/>
<label>HD_GO : <input type="text" name="HD_GO" /></label><br/>
<label>Serie : <input type="text" name="Serie" /></label><br/>
<label>Achat : <input type="text" name="Achat" /></label><br/>
<label>Fin_Garantie : <input type="text" name="Fin_Garantie" /></label><br/>
<label>OS : <input type="text" name="OS" /></label><br/>
<label>OFFICE : <input type="text" name="Office"/></label><br/>
<input type="submit" value="Rechercher"/>
</fieldset>
</form>
<?
if ($_POST['Nom_micro']=='')
{
$nom=0;
}
if ($_POST['User']=='')
{
$user=0;
}
if ($_POST['Bureau']=='')
{
$bureau=0;
}
if ($_POST['Type_micro']=='')
{
$typemicro=0;
}
if ($_POST['P_D_S']=='')
{
$PDS=0;
}
if ($_POST['mP']=='')
{
$mp=0;
}
if ($_POST['MHZ']=='')
{
$mhz=0;
}
if ($_POST['RAM']=='')
{
$ram=0;
}
if ($_POST['Type_RAM']=='')
{
$typeram=0;
}
if ($_POST['HD_GO']=='')
{
$hdgo=0;
}
if ($_POST['Serie']=='')
{
$serie=0;
}
if ($_POST['Achat']=='')
{
$achat=0;
}
if ($_POST['Fin_Garantie']=='')
{ $fingarantie=0;
}
if ($_POST['OS']=='')
{$os=0;
}
if ($_POST['Office']=='')
{$office=0;
}
$dspmic=mysql_query("SELECT * from parc_micro Where $nom='".$_POST['Nom_micro']."' and $user='".$_POST['User']."' and $bureau='".$_POST['Bureau']."' and $typemicro='".$_POST['Type_micro']."' and $PDS='".$_POST['P_D_S']."' and $mp='".$_POST['mP']."' and $mhz='".$_POST['MHZ']."' and $ram='".$_POST['RAM']."' ;");
while ($donnees=mysql_fetch_array($dspmic))
{
?><table>
<tr>
<td><? echo $donnees['Nom_micro'];?></td>
<td><? echo $donnees['User'];?></td>
<td><? echo $donnees['Bureau'];?></td>
<td><? echo $donnees['Type_micro'];?></td>
<td><? echo $donnees['P_D_S'];?></td>
<td><? echo $donnees['mP'];?></td>
<td><? echo $donnees['MHZ'];?></td>
<td><? echo $donnees['RAM'];?></td>
<td><? echo $donnees['Type_RAM'];?></td>
<td><? echo $donnees['HD_GO'];?></td>
<td><? echo $donnees['Serie'];?></td>
<td><? echo $donnees['Achat'];?></td>
<td><? echo $donnees['Fin_Garantie'];?></td>
<td><? echo $donnees['OS'];?></td>
<td><? echo $donnees['Office'];?></td>
</tr>
<?}?>
</table>
<? mysql_close();?>