Php et sql

Fermé
roujit Messages postés 26 Date d'inscription mardi 23 mars 2010 Statut Membre Dernière intervention 5 octobre 2010 - 31 mars 2010 à 17:43
DasSium95 Messages postés 673 Date d'inscription mardi 30 mars 2010 Statut Membre Dernière intervention 13 avril 2016 - 31 mars 2010 à 20:40
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>
A voir également:

4 réponses

DasSium95 Messages postés 673 Date d'inscription mardi 30 mars 2010 Statut Membre Dernière intervention 13 avril 2016 134
31 mars 2010 à 17:49
quand tu finis ton formulaire tu envois quel page?
0
roujit Messages postés 26 Date d'inscription mardi 23 mars 2010 Statut Membre Dernière intervention 5 octobre 2010
31 mars 2010 à 18:03
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
0
DasSium95 Messages postés 673 Date d'inscription mardi 30 mars 2010 Statut Membre Dernière intervention 13 avril 2016 134
31 mars 2010 à 18:20
il te manque toujours l'action dans l'en tête du form
0
roujit Messages postés 26 Date d'inscription mardi 23 mars 2010 Statut Membre Dernière intervention 5 octobre 2010
31 mars 2010 à 20:21
MERCI BIEN J'AIMERAIS TE DIRE QU'ON FIN J AI RÉSOLU MON PROBLÈME .C' ÉTAIS UNE FAUTE TRÈS DÉBILE J'ÉCRIS MÉTHODE AU LIEU DE METHOD
0
DasSium95 Messages postés 673 Date d'inscription mardi 30 mars 2010 Statut Membre Dernière intervention 13 avril 2016 134
31 mars 2010 à 20:40
di toi je l'avais même pas vu et en effet tu avais mis un "e"^^
0
roujit Messages postés 26 Date d'inscription mardi 23 mars 2010 Statut Membre Dernière intervention 5 octobre 2010
31 mars 2010 à 18:26
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>
0