<?php
$sql = "SELECT nom FROM table WHERE ...";
$query = mysl_query($sql);
$result = mysql_fetch_array($query);
?>
<input type="text" name="nom" value="<?php echo $result['nom']; ?>">
<?php
$query="INSERT INTO produit2 (nom,formule,reference,disponibilite,localisation,quantite,numero_cass,toxicite) VALUES ('".$nom."', '".$formule."', '".$reference."', '".$disponibilite."','".$localisation."','".$quantite."','".$numero_cass."','".$toxicite."');";
mysql_query($query) or die (mysql_error);
?>
<tr width="30%" height="15"><td><b>Nom de la molécule :</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><?php print $row['nom']; ?></b></td>
<td><b><input type="text" name="nom"></b></td></tr>
<tr width="30%" height="29"><td><b>Formule brute de la molecule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><?php print $row['formule']; ?></b></td>
<td><b><input type="text" name="formule"></b></td></tr>
sinon pour la requete update if (empty($nom2)){
$nom2 = $nom1
}else{$nom2 = $nom2}
c'est mieu comme sa??$query="UPDATE table SET nom='$nom2', formule='$formule2', localisation='$localisation2', disponibilite='$disponibilite2', quantite='$quantite', reference='$reference2', numero_cass='$numero_cass2', toxicite='$toxicite2'";
$resultat=mysql_query($query);
C'est bon comme sa
if (empty($nom2)){
$nom2 = $nom1
}else{$nom2 = $nom2}
il ne te sert a rien de dire que $nom2=$nom2 (c'est comme dire 1=1 !! si pjl passe par la ...)if (empty($nom2)){
$nom2 = $nom1;
}
$query="UPDATE table SET nom='$nom2', formule='$formule2', localisation='$localisation2', disponibilite='$disponibilite2', quantite='$quantite', reference='$reference2', numero_cass='$numero_cass2', toxicite='$toxicite2'";
echo $query;
$resultat=mysql_query($query) or die(mysql_error());
UPDATE produit2 SET nom='essais2', formule='essais', localisation='esssais', disponibilite='essais', quantite='essais', reference='2334', numero_cass='essais', toxicite='essais'
pourtant tout me semble bon : //<?php
$host = '********';
$user = '*******';
$pass = '********';
$db = '************';
// connection à la DB
$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error() );
mysql_select_db($db) or die ('Erreur :'.mysql_error());
$id =$_GET['id'];
$select = "SELECT * FROM produit2 WHERE reference LIKE '$id'";
$result = mysql_query($select,$link) or die ('Erreur : '.mysql_error() );
$row = mysql_fetch_assoc($result);
$nom = $row['nom'];
$formule = $row['formule'];
$reference = $row['reference'];
$num = $row['numero_cass'];
$toxicite = $row['toxicite'];
$localisation = $row['localisation'];
$disponibilite = $row['disponibilite'];
$quantite = $row['quantite'];
$nom2 = $_POST['nom'];
$formule2 = $_POST['formule'];
$reference2 = $_POST['reference'];
$num2 = $_POST['numero_cass'];
$toxicite2 = $_POST['toxicite'];
$localisation2 = $_POST['localisation'];
$disponibilite2 = $_POST['disponibilite'];
$quantite2 = $_POST['quantite'];
$numero_cass2 = $_POST['numero_cass'];
if(isset($_POST['envoi']))
{
if ($nom == '' || $formule == '' || $localisation == '' || $quantite == '' || $reference == '' || $numero_cass == '')
{
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table summary="">
<col width="250" title="titres" />
<col width="15" title="oblige" />
<col width="250" title="nouvelle_donnees" />
<tr width="30%" height="15"><td><b>Nom de la molécule :</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="nom" value="<?php echo $row['nom']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Formule brute de la molecule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="formule" value="<?php echo $row['formule']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Localisation de la Molécule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="localisation" value="<?php echo $row['localisation']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Disponibilité :</b></td>
<td><div style="color: #ffffff; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="disponibilite" value="<?php echo $row['disponibilite']; ?>"></b></td></tr>
<tr width="30%" height="15"><td><b>Quantité en reserve :</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="quantite" value="<?php echo $row['quantite']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Reference de la molecule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="reference" value="<?php echo $row['reference']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Numero de CAS:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="numero_cass" value="<?php echo $row['numero_cass']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Toxicite :</b></td>
<td><div style="color: #ffffff; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="toxicite" value="<?php echo $row['toxicite']; ?>"></b></td></tr>
<tr><td colspan="4"><div style="text-align:center;"><input type="submit" class="verif" name="envoi" value="Envoyer" />
<input type="reset" class="verif" value="Tout effacer" /><input type="submit" value="Imprimer" onclick="print();">
<input type="submit" value="fermer" onClick="window.close()";></div></td></tr>
</TABLE></form>
<?php
}
else{
/* Affichage du message final des informations reçues */
print "<h3>Merci ! Voici les modifications que vous avez fournies pour cette molécule</h3>\n";
print "<p>Informations sur la nouvelle molecule:</p>\n";
print "<b>Son nom :</b>".$nom2."<br />\n";
print "<b>Sa formule Brute :</b>".$formule2."<br />\n";
print "<b>Sa localisation :</b>".$localisation2."<br />\n";
print "<b>Sa quantite en reserve :</b>".$quantite2."<br />\n";
print "<b>Sa reference :</b>".$reference2."<br />\n";
print "<b>Son numero de CASE :</b>".$numero_cass2."<br />\n";
if ($toxicite !==''){
print "<b>Sa toxicite s'il y en a une :</b> ".$toxicite2."<br />\n";
}
print("<p>Retour vers le formulaire de recherche pour modification, cliquez <a href=\"modifier.php\" title=\"Retour vers le formulaire\">ICI</a></p>");
print("<p>Retour vers l'Index, cliquez <a href=\"index.html\" title=\"Retour a l'index\">ICI</a></p>");
$host = '*****';
$user = '*******';
$pass = '********';
$db = '*************';
// connection à la DB
$link = mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error() );
mysql_select_db($db) or die ('Erreur :'.mysql_error());
$query="UPDATE produit2 SET nom='$nom2', formule='$formule2', localisation='$localisation2', disponibilite='$disponibilite2', quantite='$quantite', reference='$reference2', numero_cass='$numero_cass2', toxicite='$toxicite2'";
$resultat=mysql_query($query);
echo $query;
}
}
else
{
?>
<H3><strong>Formulaire de modification de produits</strong></H3>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table summary="">
<col width="250" title="titres" />
<col width="15" title="oblige" />
<col width="250" title="nouvelle_donnees" />
<tr width="30%" height="15"><td><b>Nom de la molécule :</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="nom" value="<?php echo $row['nom']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Formule brute de la molecule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="formule" value="<?php echo $row['formule']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Localisation de la Molécule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="localisation" value="<?php echo $row['localisation']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Disponibilité :</b></td>
<td><div style="color: #ffffff; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="disponibilite" value="<?php echo $row['disponibilite']; ?>"></b></td></tr>
<tr width="30%" height="15"><td><b>Quantité en reserve :</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="quantite"value="<?php echo $row['quantite']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Reference de la molecule:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="reference" value="<?php echo $row['reference']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Numero de CAS:</td>
<td><div style="color: #ff0000; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="numero_cass" value="<?php echo $row['numero_cass']; ?>"></b></td></tr>
<tr width="30%" height="29"><td><b>Toxicite :</b></td>
<td><div style="color: #ffffff; text-align: center; font-weight: bold"></div></td>
<td><b><input type="text" name="toxicite" value="<?php echo $row['toxicite']; ?>"></b></td></tr>
<tr><td colspan="4"><div style="text-align:center;"><input type="submit" class="verif" name="envoi" value="Envoyer" />
<input type="reset" class="verif" value="Tout effacer" /><input type="submit" value="Imprimer" onclick="print();">
<input type="submit" value="fermer" onClick="window.close()";></div></td></tr>
</TABLE></form>
<?php
}
?>
$query="UPDATE produit2 SET nom='$nom2', formule='$formule2', localisation='$localisation2', disponibilite='$disponibilite2', quantite='$quantite', reference='$reference2', numero_cass='$numero_cass2', toxicite='$toxicite2' where reference like $reference";
$resultat=mysql_query($query);
merci de m'avoir prevenu sinon j'aurai quelques petit probleme ..
$query="UPDATE produit2 SET nom='$nom2', formule='$formule2', localisation='$localisation2', disponibilite='$disponibilite2', quantite='$quantite', reference='$reference2', numero_cass='$numero_cass2', toxicite='$toxicite2' where reference like $reference";
$resultat=mysql_query($query,$link) or die ('Erreur : '.mysql_error() );
echo $query;