Php et sql
roujit
Messages postés
28
Statut
Membre
-
DasSium95 Messages postés 741 Statut Membre -
DasSium95 Messages postés 741 Statut Membre -
voila DasSium95?,mon code du formulaire
<html>
<head>
<title>modification de données</title>
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass)or die('error connecting to mysql');
$dbname = 'asta';
mysql_select_db($dbname);
$id_devis=$_POST["id_devis"];
$jour=$_POST["jour"];
$mois=$_POST["mois"];
$annee=$_POST["annee"];
$description_devis=$_POST["description_devis"];
$montant=$_POST["montant"];
$remise=$_POST["remise"];
$var=$_GET['var'];
// print $_GET['var'];
?><br><br><?php
$date=$annee."-".$mois."-".$jour;
$query="select * from devis where id_devis='$var'";
//echo $query;
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result)){
?>
<form methode="post" name="deposer" >
<table width="366" border="0" align="center">
<input type="hidden" name="id_devis" value="<?php print("$row[id_devis]");?>">
<tr bgcolor="#969696">
<td width="134" align="right">
Date
</td>
<td width="222">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[date]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Description Devis
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[description_devis]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Montant
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[montant]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="134" align="right">
Remise
</td>
<td width="222">
<input name="remise" type="text" maxlength="20" value=
"<?php
print("$row[remise]");
?>">
</td>
</tr>
</table><br>
<center> <INPUT TYPE="SUBMIT" VALUE="modifier" >
<input type="reset" value= "Annuler" ></center></p>
</form>
<?php
}
?>
</body>
</html>
voila mon code du modification
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<?PHP
$id_devis=$_POST["id_devis"];
$id_client=$_POST["id_client"];
$id_panne=$_POST["id_panne"];
$date=$_POST["date"];
$description_devis=$_POST["description_devis"];
$montant=$_POST["montant"];
$remise=$_POST["remise"];
$var1=$_GET['var1'];
echo $var1;
$var2=$_GET['var2'];
echo $var2;
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass)or die('error connecting to mysql');
$dbname = 'asta';
mysql_select_db($dbname);
$query="UPDATE devis SET remise='$remise' where remise='$var2' ";
$result = mysql_query($query) or die(mysql_error());
echo $query;
?>
</body>
</html>
</body>
</html>
<html>
<head>
<title>modification de données</title>
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass)or die('error connecting to mysql');
$dbname = 'asta';
mysql_select_db($dbname);
$id_devis=$_POST["id_devis"];
$jour=$_POST["jour"];
$mois=$_POST["mois"];
$annee=$_POST["annee"];
$description_devis=$_POST["description_devis"];
$montant=$_POST["montant"];
$remise=$_POST["remise"];
$var=$_GET['var'];
// print $_GET['var'];
?><br><br><?php
$date=$annee."-".$mois."-".$jour;
$query="select * from devis where id_devis='$var'";
//echo $query;
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result)){
?>
<form methode="post" name="deposer" >
<table width="366" border="0" align="center">
<input type="hidden" name="id_devis" value="<?php print("$row[id_devis]");?>">
<tr bgcolor="#969696">
<td width="134" align="right">
Date
</td>
<td width="222">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[date]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Description Devis
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[description_devis]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Montant
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[montant]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="134" align="right">
Remise
</td>
<td width="222">
<input name="remise" type="text" maxlength="20" value=
"<?php
print("$row[remise]");
?>">
</td>
</tr>
</table><br>
<center> <INPUT TYPE="SUBMIT" VALUE="modifier" >
<input type="reset" value= "Annuler" ></center></p>
</form>
<?php
}
?>
</body>
</html>
voila mon code du modification
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<?PHP
$id_devis=$_POST["id_devis"];
$id_client=$_POST["id_client"];
$id_panne=$_POST["id_panne"];
$date=$_POST["date"];
$description_devis=$_POST["description_devis"];
$montant=$_POST["montant"];
$remise=$_POST["remise"];
$var1=$_GET['var1'];
echo $var1;
$var2=$_GET['var2'];
echo $var2;
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass)or die('error connecting to mysql');
$dbname = 'asta';
mysql_select_db($dbname);
$query="UPDATE devis SET remise='$remise' where remise='$var2' ";
$result = mysql_query($query) or die(mysql_error());
echo $query;
?>
</body>
</html>
</body>
</html>
4 réponses
-
-
la page modification2.php qui contient la requête de modification
et sa affiche celui ci
UPDATE devis SET remise='' where remise='10'
cad qu'il a récupérer la valeur du champ remise afficher dans le formulaire mais pas la nouvelle valeur que j'ai fais entrer pour modifier le champ remise -
il te manque toujours l'action dans l'en tête du form
-
PARDON JE ME SUIS TROMPE VOICI LE CODE
<html>
<head>
<title>modification de données</title>
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass)or die('error connecting to mysql');
$dbname = 'asta';
mysql_select_db($dbname);
$id_devis=$_POST["id_devis"];
$jour=$_POST["jour"];
$mois=$_POST["mois"];
$annee=$_POST["annee"];
$description_devis=$_POST["description_devis"];
$montant=$_POST["montant"];
$remise=$_POST["remise"];
$var=$_GET['var'];
// print $_GET['var'];
?><br><br><?php
$date=$annee."-".$mois."-".$jour;
$query="select * from devis where id_devis='$var'";
//echo $query;
$result = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result)){
?>
<form methode="post" name="deposer" action="modification2.php">
<table width="366" border="0" align="center">
<input type="hidden" name="id_devis" value="<?php print("$row[id_devis]");?>">
<tr bgcolor="#969696">
<td width="134" align="right">
Date
</td>
<td width="222">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[date]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Description Devis
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[description_devis]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="700" align="right">
Montant
</td>
<td width="500">
<input name="date" type="text" maxlength="20" value="<?php
print("$row[montant]");
?>">
</td>
</tr>
<tr bgcolor="#969696">
<td width="134" align="right">
Remise
</td>
<td width="222">
<input name="remise" type="text" maxlength="20" value=
"<?php
print("$row[remise]");
?>">
</td>
</tr>
</table><br>
<center>
<?php echo'<a href="modification2.php?var1='.$row[id_devis].'& var2='.$row[remise].'">modifier</a>'?>
<input type="reset" value= "Annuler" ></center></p>
</form>';
</form>
<?php
}
?>
</body>
</html>