Pourquoi j'ai pas d'insertion dans ma table

Résolu
msi79 - Modifié par jee pee le 7/10/2013 à 18:59
BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 - 8 oct. 2013 à 15:19
bonjour à tous depuis hier je cherche le problème dans mon code. j'arrive pas a savoir pourquoi il n 'a pas d'insertion dans ma table
voici la stucture de ma table:

- Base de données: 'bdd'
--

-- --------------------------------------------------------

--
-- Structure de la table 'etat_taxation'
--

CREATE TABLE IF NOT EXISTS 'etat_taxation' (
  'id' int(11) NOT NULL AUTO_INCREMENT,
  'date_impos' varchar(60) NOT NULL,
  'noms' varchar(200) NOT NULL,
  'ncc' varchar(30) NOT NULL,
  'ref_facture' varchar(60) NOT NULL,
  'natur_bien' varchar(60) NOT NULL,
  'montant_total' varchar(30) NOT NULL,
  'mont_tax_deduct' varchar(30) NOT NULL,
  'code' int(11) NOT NULL,
  'get_id' int(11) NOT NULL,
  PRIMARY KEY ('id')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
COMMIT;


et voici mon code :
<?php
if(!isset($_SESSION['pseudo'])){
header("location: index.php?page=BIENVENUE");
}
if(isset($_GET['id'])) $id = urldecode($_GET['id']);

    if(isset($_POST['bouton_submit']) && !empty($_POST['nbre'])){
  //$cat = strip_tags(trim($_POST['cat'])); 
  for($i = 1; $i <= $_POST['nbre']; $i++){
       if (empty($code)) {
  $msg="<font color=red>Verifier que le code est bien dans le champs!!!!!!!!!</font>";
 }
 else {
  // on regarde si l'url existe déjà 
    $sql = "SELECT * FROM etat_taxation WHERE code='$code'"; 
    $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());  
     
    // on compte le nombre de résultats 
    $res = mysql_num_rows($req); 

      if($res!=0)  // l'url existe déjà, on affiche un message d'erreur 
        { 
             $msg = 'Désolé, mais cette Code  existe déjà dans notre base.'; 
             echo '<script>alert(' '.$msg.' ');</script>' ;
        } 
     else  // L'url n'existe pas, on insère les informations du formulaire dans la table 
        { 
       $date_impos = mysql_real_escape_string(htmlentities(trim($_POST['date_impos'.$i])));
    $noms =  mysql_real_escape_string(htmlentities(trim($_POST['noms'.$i])));
    $ncc =  mysql_real_escape_string(htmlentities(trim($_POST['ncc'.$i])));
    $ref_facture =  mysql_real_escape_string(htmlentities(trim($_POST['ref_facture'.$i])));
    $natur_bien =  mysql_real_escape_string(htmlentities(trim($_POST['natur_bien'.$i])));
    $montant_total =  mysql_real_escape_string(htmlentities(trim($_POST['montant_total'.$i])));
    $mont_tax_deduct = mysql_real_escape_string(htmlentities(trim($_POST['mont_tax_deduct'.$i])));
    $code =  mysql_real_escape_string(htmlentities(trim($_POST['code'])));
   
creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); 
}}}}
?>
<!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>
<link rel="stylesheet" href="css/style_f.css" />
</head>

<body>
<div style="background-color: #FFFFFF; width: 960px; height: 1500px; position: absolute; top: 17px; left: 16px; z-index: -2000">
<div style="position: absolute; top: 11px; left: 780px"><img src="images/BV.png" width="100" height="50" /></div>
<div  style="text-align: center; background-color: #ccc; width: 500px; left: 201px; position: absolute; top: 25px; z-index: -1000;">ETAT DES TAXATIONS DEDUCTIBLES</div>
<p> </p>
<div style="position:absolute; top:200px; left:25px">
<fieldset style="width: 814px; border-color: #1E1E1E; position: absolute; top: -132px; left: -12px; height: auto;" >
<legend><span class="Style2"> ETAT DES TAXATIONS DEDUCTIBLES</span></legend>
<form class="formulaire" name="form1" method="post" action="">
<table width="312" border="0">
  <tr>
    <td width="121">Saisir le nombre</td>
    <td width="33"><input name="nbre" type="text" size="1" maxlength="1" value="<?php if(isset($_POST['nbre']))echo $_POST['nbre'];?>"/></td>
    <td width="34"> </td>
  </tr>
</table>


  <table width="806" height="162" border="0" bgcolor="#fff align="center">
    <tr>
      <td width="707" colspan="7"><?php if(isset($_POST['bouton_submit']) && ($_POST['nbre'])){ extract($_POST); $nbre_photo = $nbre; for($j = 1; $j<= $nbre_photo; $j++){ 
   //ENREGISTREMENT DU CODE
    $sql = ('SELECT (max(code)+1) AS code FROM etat_taxation');
 $q = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
 while($row = mysql_fetch_assoc($q)){ $code = $row["code"];  }
   echo'
   <table width="860" height="45" border="0" bgcolor="#fff align="center="center"">
  <tr>
    <td width="111"><input type="text" name="date_impos'.$j.'" id="date_impos" style="width:80px; text-align:center"" placeholder="Date" /></td>
    <td width="206" height="41"><input type="text" name="noms'.$j.'" id="noms" style="width:150px; text-align:center"" placeholder="Noms"  /></td>
    <td width="85" height="41"><input type="text" name="ncc'.$j.'" style="width:60px" id="ncc" placeholder="NCC" /></td>
    <td width="125" height="41"><input type="text" name="ref_facture'.$j.'" id="ref_facture" style="width:80px" placeholder="Ref"; text-align:center" /></td>
    <td width="118" height="41"><input type="text" name="natur_bien'.$j.'" id="natur_bien" style="width:80px; text-align:center"" placeholder="Nat B." /></td>
    <td width="115"><input type="text" name="montant_total'.$j.'" id="montant_total" style="width:80px; text-align:center"" placeholder="MT" /></td>
    <td width="250" height="41"><input type="text" name="mont_tax_deduct'.$j.'" id="mont_tax_deduct" style="width:80px; text-align:center" placeholder="MTD" /></td>
 <td width="250" height="41"><input type="text" name="code'.$j.'" id="code" value="'.$code.'" style="width:80px;background-color:#E8E8E8; text-align:center"" placeholder="Code" /></td>
  </tr>
</table>
   
   
 ';}
  }
?></td>
    </tr>
  </table>
  <input type="submit" name="bouton_submit" value="envoyer" ></input>
</form>
</fieldset>



<p> </p>
</body>
</html>

9 réponses

jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
8 oct. 2013 à 01:02
Bonsoir;

pourquoi il n 'a pas d'insertion dans ma table


Dans le code que tu nous as fourni, je ne vois pas de requête INSERT (il y a bien une fonction "creer_etat_taxation" qui pourrait, vu son nom, servir à ça.. mais sans son code.....


Je ne vois pas non plus d'action pour ton FORM.
<form class="formulaire" name="form1" method="post" action="">


Quoi qu'il en soit, je t'invite à ( dans l'ordre )

- Ajouter des ECHO (ou des print_r ) aux différentes lignes "clés" de ton programme pour voir si tes variables (et tes requêtes) correspondent bien à ce que tu attends.

- Tester ta requête INSERT (une fois récupérée via un echo ) directement dans ta BDD pour voir s'il n'y a pas de message d'erreur.

- Nous montrer ton code d'INSERT pour que l'on puisse essayer de voir ce qui pourrait bloquer.[en nous faisant part des résultats des tests précédents ci-dessus]


PS: en règle général, PHP est assez "bavard" lorsqu'il rencontre des soucis.... n'aurais-tu pas un message d'erreur ?




0
bonjour merci de bien vouloir m'aider.
effectivement la fonction se trouve dans la page page.func.php
<?php
//la function qui  va creer la conversation et le message qui va avec
function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){
if(isset($_GET['id'])) $id = urldecode($_GET['id']);
mysql_query("
  INSERT INTO etat_taxation (id,date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('','{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}')
") or die(mysql_error());
}
?>
0
jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
8 oct. 2013 à 10:18
Je vois que tu ajoutes un id -> vide...
Si il est auto_incrémenté comme je le pense, enlève le !

Ensuite dans ta fonction retire le 'die' et modifie la comme ceci :
function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){
if(isset($_GET['id'])) $id = urldecode($_GET['id']);
  $sql = " INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}'))"; 
  mysql_query($sql);
 return $sql;
}


et lors de l'appel de ta fonction :

$requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); 

Echo $requete ;



regardes ensuite ta requête ainsi générée et teste là en direct dans ta BDD.. tu devrais voir le message d'erreur qui correspond à ton souci (si celui-ci persiste )
0
je viens de faire tout ce que tu m'as conseillé mais toujours pas d'insertion dans la table
voici la nouvelle structure de ma table


-- Structure de la table 'etat_taxation'

CREATE TABLE IF NOT EXISTS 'etat_taxation' (
'date_impos' varchar(60) NOT NULL,
'noms' varchar(200) NOT NULL,
'ncc' varchar(30) NOT NULL,
'ref_facture' varchar(60) NOT NULL,
'natur_bien' varchar(60) NOT NULL,
'montant_total' varchar(30) NOT NULL,
'mont_tax_deduct' varchar(30) NOT NULL,
'code' int(11) NOT NULL,
'get_id' int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
COMMIT;

page.php
<?php
if(!isset($_SESSION['pseudo'])){
header("location: index.php?page=BIENVENUE");
}
if(isset($_GET['id'])) $id = urldecode($_GET['id']);

    if(isset($_POST['bouton_submit']) && !empty($_POST['nbre'])){
    $date_impos = mysql_real_escape_string(htmlentities(trim($_POST['date_impos'])));
    $noms =  mysql_real_escape_string(htmlentities(trim($_POST['noms'])));
    $ncc =  mysql_real_escape_string(htmlentities(trim($_POST['ncc'])));
    $ref_facture =  mysql_real_escape_string(htmlentities(trim($_POST['ref_facture'])));
    $natur_bien =  mysql_real_escape_string(htmlentities(trim($_POST['natur_bien'])));
    $montant_total =  mysql_real_escape_string(htmlentities(trim($_POST['montant_total'])));
    $mont_tax_deduct = mysql_real_escape_string(htmlentities(trim($_POST['mont_tax_deduct'])));
    $code = mysql_real_escape_string(htmlentities(trim($_POST['code'])));
  //$cat = strip_tags(trim($_POST['cat'])); 
  for($i = 1; $i <= $_POST['nbre']; $i++){
       if (empty($code)) {
  $msg="<font color=red>Verifier que le code est bien dans le champs!!!!!!!!!</font>";
 }
 else {
  // on regarde si le code existe déjà 
    $sql = "SELECT * FROM etat_taxation WHERE code='$code'"; 
    $req = mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());  
     
    // on compte le nombre de résultats 
    $res = mysql_num_rows($req); 

      if($res!=0)  // l'url existe déjà, on affiche un message d'erreur 
        { 
             $msg = 'Désolé, mais cette Code  existe déjà dans notre base.'; 
             echo '<script>alert(' '.$msg.' ');</script>' ;
        } 
     else  // L'url n'existe pas, on insère les informations du formulaire dans la table 
        { 
   // if(isset($_POST['submit'])){

   
//creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id); 
$requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); 

Echo $requete ;
}}}}
?>
<!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>
<link rel="stylesheet" href="css/style_f.css" />
</head>

<body>
<div style="background-color: #FFFFFF; width: 960px; height: 1500px; position: absolute; top: 17px; left: 16px; z-index: -2000">
<div style="position: absolute; top: 11px; left: 780px"><img src="images/BV.png" width="100" height="50" /></div>
<div  style="text-align: center; background-color: #ccc; width: 500px; left: 201px; position: absolute; top: 25px; z-index: -1000;">ETAT DES TAXATIONS DEDUCTIBLES</div>
<p> </p>
<div style="position:absolute; top:200px; left:25px">
<fieldset style="width: 814px; border-color: #1E1E1E; position: absolute; top: -132px; left: -12px; height: auto;" >
<legend><span class="Style2"> ETAT DES TAXATIONS DEDUCTIBLES</span></legend>
<form class="formulaire" name="form1" method="post" action="">
  <table width="312" border="0">
    <tr>
      <td width="121">Saisir le nombre</td>
      <td width="33"><input name="nbre" type="text" size="1" maxlength="1" value="<?php if(isset($_POST['nbre']))echo $_POST['nbre'];?>"/></td>
      <td width="34"> </td>
    </tr>
  </table>
  <p>
    <?php if(isset($_POST['bouton_submit']) && ($_POST['nbre'])){ extract($_POST); $nbre_photo = $nbre; for($j = 1; $j<= $nbre_photo; $j++){ 
   //ENREGISTREMENT DU CODE
    $sql = ('SELECT (max(code)+1) AS code FROM etat_taxation');
 $q = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
 while($row = mysql_fetch_assoc($q)){ $code = $row["code"];  }
   echo'
   <table width="860" height="45" border="0" bgcolor="#fff align="center="center"">
  <tr>
    <td width="111"><input type="text" name="date_impos'.$j.'" id="date_impos" style="width:80px; text-align:center"" placeholder="Date" /></td>
    <td width="206" height="41"><input type="text" name="noms'.$j.'" id="noms" style="width:150px; text-align:center"" placeholder="Noms"  /></td>
    <td width="85" height="41"><input type="text" name="ncc'.$j.'" style="width:60px" id="ncc" placeholder="NCC" /></td>
    <td width="125" height="41"><input type="text" name="ref_facture'.$j.'" id="ref_facture" style="width:80px" placeholder="Ref"; text-align:center" /></td>
    <td width="118" height="41"><input type="text" name="natur_bien'.$j.'" id="natur_bien" style="width:80px; text-align:center"" placeholder="Nat B." /></td>
    <td width="115"><input type="text" name="montant_total'.$j.'" id="montant_total" style="width:80px; text-align:center"" placeholder="MT" /></td>
    <td width="250" height="41"><input type="text" name="mont_tax_deduct'.$j.'" id="mont_tax_deduct" style="width:80px; text-align:center" placeholder="MTD" /></td>
 <td width="250" height="41"><input type="text" name="code'.$j.'" id="code" value="'.$code.'" style="width:80px;background-color:#E8E8E8; text-align:center"" placeholder="Code" /></td>
  </tr>
</table>
   
   
 ';}
  }
?>
    <input type="submit" name="bouton_submit" value="envoyer" />
  </p>
</form></input>
</form>
</fieldset>

</body>
</html>


et enfin page.func.php
<?php


function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){
if(isset($_GET['id'])) $id = urldecode($_GET['id']);

$sql = "INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('{$date_impos}','{$noms}','{$ncc}','{$ref_facture}',{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}')";
  mysql_query($sql);
 return $sql;
}
?>
0
BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 103
8 oct. 2013 à 12:57
Hello,
J'ai corrigé l'affichage des balises code
0
msi79 Messages postés 509 Date d'inscription lundi 24 août 2009 Statut Membre Dernière intervention 2 mai 2023 1
8 oct. 2013 à 13:06
comment ça je comprend pas . ou est ce que tu as corrigé
0
BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 103
8 oct. 2013 à 13:34
0
jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
8 oct. 2013 à 13:35
Il a mis ton code dans les balises permettant d'avoir la coloration syntaxique...
Ceci est du code dans les balises < code > !
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
8 oct. 2013 à 13:43
donc re-bonjour,

voici la nouvelle structure de ma table
- Pourquoi avoir modifié la structure de ta table ?
- Ou est ta Primary Key (anciennement l'ID ) ?
- Est-ce que l'ECHO de ta requête t'a affiché quelque chose ?
-> Si oui, as tu essayé cette requête directement dans ta BDD via Php/MyAdmin par exemple ?

Ta ligne :
if(isset($_GET['id'])) $id = urldecode($_GET['id']);
me parait étrange...
- N'aurais tu pas oublié les " { } " ?
- Ou fait un Mix (raté) avec la syntaxe alternative ?

Vu que dans ta base tu as indiqué que tes champs sont : NOT NULL, es-tu sûr que toutes tes variables que tu essaies d'insérer dans ta table sont bien renseignées (tu peux le voir lors du echo $requete.. )


Répond à chacune de ces questions et nous pourrons peut-être avancer sur ton souci.
N'hésites pas à nous coller un exemple de ce que ton Echo $requête t'affiche pour qu'on essaie de comprendre.



0
msi79 Messages postés 509 Date d'inscription lundi 24 août 2009 Statut Membre Dernière intervention 2 mai 2023 1
8 oct. 2013 à 13:44
ah ook je comprend . mais j'arrive pas toujours a inserrer mes données
0
jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
8 oct. 2013 à 13:58
ah ook je comprend . mais j'arrive pas toujours a inserrer mes données
Tu comprends quoi ?
Tu peux répondre à mes questions précédentes ? (nous dire ce que chaque test donne... ce que tu as essayé.... ce qui bloque... si tu as des messages d'erreurs ... ??? )
0
msi79 Messages postés 509 Date d'inscription lundi 24 août 2009 Statut Membre Dernière intervention 2 mai 2023 1
8 oct. 2013 à 14:03
j'ai testé dans la BDD et xa marche bien la bas

- voici ce que j'ai essayé dans la BDD
INSERT INTO etat_taxation (date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('07/10/2013','ECOGEP-CI','010075E','3-1-5-0519626','MATERIELS','260455','39733','1','1');



- essuite quand je fais echo ça n'affiche rien . pas de message .
- j'ai remis le ID

- je viens de verifier tous les " { } " et tout est correct

- je compren pas cette question "- Ou fait un Mix (raté) avec la syntaxe alternative ?"

- oui toutes les variables sont bien renseignées

mais toujours rien
0
jordane45 Messages postés 38136 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 16 avril 2024 344
Modifié par jordane45 le 8/10/2013 à 14:17
La ligne que tu as testé dans ta bdd, c'est celle issue de ton ECHO ?

essuite quand je fais echo ça n'affiche rien
Ah.. donc tu ne sors pas de ta fonction (ou voir même tu n'y rentre pas).


Ajoutes donc un Echo $id juste en dessous de ta ligne : isset($_GET['id']))

Ajoute aussi un echo juste avant d'appeler ta fonction

Echo "<br> ----- CREATION ETAT TAXATION ---------<br>";

//creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id); 
$requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$id); 

Echo "<br>Requete = ". $requete ;


Est-ce que lorsque tu exécutes ta page, tu visualise bien l'écho ou pas ? .. Si tu ne le vois pas... c'est que tes tests ( IF ) ne sont pas bons...
0
msi79 Messages postés 509 Date d'inscription lundi 24 août 2009 Statut Membre Dernière intervention 2 mai 2023 1
8 oct. 2013 à 14:51
jai viré
	     // if (empty($code)) {
		//$msg="<font color=red>Verifier que le code est bien dans le champs!!!!!!!!!</font>";
	//}
	//else {


mais le code reagit pas comme je voudrais .
d'abord quand je saisis le nombre il doit affiche le nombre de ligne correspondant a ce nombre quand je click sur le bouton submit .
mais lui deja il fait une insersion
0
msi79 Messages postés 509 Date d'inscription lundi 24 août 2009 Statut Membre Dernière intervention 2 mai 2023 1
8 oct. 2013 à 15:14
merci pour votre aide tout marche bien voici le code final

page.php
<?php
if(isset($_GET['id'])); 
$id =$_GET['id'];
echo $id;
if(isset($_POST['bouton_submit'])&& !empty($_POST['nbre'])){
$cat = strip_tags(trim($_POST['cat'])); 
for($i = 1; $i <= $_POST['nbre']; $i++){
$date_impos = mysql_real_escape_string(htmlspecialchars(trim($_POST['date_impos'.$i])));
$noms = mysql_real_escape_string(htmlspecialchars(trim($_POST['noms'.$i])));
$ncc = mysql_real_escape_string(htmlspecialchars(trim($_POST['ncc'.$i])));
$ref_facture = mysql_real_escape_string(htmlspecialchars(trim($_POST['ref_facture'.$i])));
$natur_bien = mysql_real_escape_string(htmlspecialchars(trim($_POST['natur_bien'.$i])));
$montant_total = mysql_real_escape_string(htmlspecialchars(trim($_POST['montant_total'.$i])));
$mont_tax_deduct = mysql_real_escape_string(htmlspecialchars(trim($_POST['mont_tax_deduct'.$i])));
$code = mysql_real_escape_string(htmlspecialchars(trim($_POST['code'.$i])));
if (empty($code)) {
		$msg="<font color=red>Veuillez saisir  le code !!!!!!!!!</font>";
	}else{
$requete = creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id);
echo $requete ;

      }
    }
}


//}

?>
<!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=iso-8859-1" />
<title>Document sans titre</title>
</head>

<body>

<div style="position:absolute; top:600px; left:295px">
<fieldset style="width: 921px; border-color: #1E1E1E; position: absolute; top: -570px; left: -292px; height: auto;" >
<legend><span class="Style2"> RESULTATS ETAT DES TAXATIONS DEDUCTIBLES</span></legend>
<form action="" method="post" >
  <table width="1195" height="95" border="0" align="center" bordercolor="#FFF" > 
  
  <tr> 
    <td width="1115">Saisir le nombre :<input name="nbre" type="text" size="1" maxlength="1" value="<?php if(isset($_POST['nbre']))echo $_POST['nbre'];?>"/></td> </tr> <tr> <td bordercolor="#0000FF"> <fieldset style="background-color:#FFF; height:250px; width:400px; border-color:#1B1B1B;"> <legend><span class="Style6">AJOUTER </span></legend>	   
  <?php if(isset($_POST['bouton_submit']) && ($_POST['nbre'])){ extract($_POST); $nbre_photo = $nbre; for($j = 1; $j<= $nbre_photo; $j++){
		  //ENREGISTREMENT DU CODE
	   $sql = ('SELECT (max(code)+1) AS code FROM etat_taxation');
 $q = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
 while($row = mysql_fetch_assoc($q)){ $code = $row["code"];  }
 echo'
   <table width="860" height="45" border="0" bgcolor="#fff align="center="center"">
  <tr>
    <td width="111"><input type="text" name="date_impos'.$j.'" id="date_impos" style="width:80px; text-align:center"" placeholder="Date" /></td>
    <td width="206" height="41"><input type="text" name="noms'.$j.'" id="noms" style="width:150px; text-align:center"" placeholder="Noms"  /></td>
    <td width="85" height="41"><input type="text" name="ncc'.$j.'" style="width:60px" id="ncc" placeholder="NCC" /></td>
    <td width="125" height="41"><input type="text" name="ref_facture'.$j.'" id="ref_facture" style="width:80px" placeholder="Ref"; text-align:center" /></td>
    <td width="118" height="41"><input type="text" name="natur_bien'.$j.'" id="natur_bien" style="width:80px; text-align:center"" placeholder="Nat B." /></td>
    <td width="115"><input type="text" name="montant_total'.$j.'" id="montant_total" style="width:80px; text-align:center"" placeholder="MT" /></td>
    <td width="250" height="41"><input type="text" name="mont_tax_deduct'.$j.'" id="mont_tax_deduct" style="width:80px; text-align:center" placeholder="MTD" /></td>
	<td width="250" height="41"><input type="text" name="code'.$j.'" id="code" value="'.$code.'" style="width:80px;background-color:#E8E8E8; text-align:center"" placeholder="Code" /></td>
  </tr>
</table>
	'; } }
 ?>
    </fieldset> </td> </tr> <tr> <td><input type="submit" name="bouton_submit" value="envoyer" ></input></td> </tr></table>
</form></fieldset>
</div>





<?php 

$color=array('#333333','#999999');
$i=0;
// on crée la requête SQL
$sql = "SELECT *
         FROM etat_taxation WHERE code = '".$_POST['code']."'";

// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$res = mysql_num_rows($req);                               // 4 
?> 
<div style="position:absolute; top:600px; left:295px">
<fieldset style="width: 921px; border-color: #1E1E1E; position: absolute; top: 37px; left: -285px; height: auto;" >
<legend><span class="Style2"> RESULTATS ETAT DES TAXATIONS DEDUCTIBLES</span></legend>
  <table width="900" style=" border-width:5px; border-style:solid; border-color:red;width:100%; align="center" "  border="0" align="center" cellspacing="2">
    <tr bgcolor="#999999"> </tr>
    <tr bgcolor="#999999">
      <th width="86" bgcolor="#fff" scope="row" style=" border-width:2px; border-style:solid; border-color:red;width:18%; " ><p class="Style8">DATE DE LA FACTURE OU DE L IMPOSITION</p></th>
      <td width="101" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:28%; " ><div align="center" class="Style10">NOM ET PRENOMS</div></td>
      <td width="113" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:10%; " ><div align="center" class="Style10">N° CC</div></td>
      <td width="119" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:30%; " ><div align="center" class="Style10">REFERENCE DE LA FACTURE OU N° DE LA DECLARATION ET DE LA LIQUIDATION DOUANE</div></td>
      <td width="62" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10">
        <p>NATURE DES BIENS OU SERVICES</p>
        <p>(ouvrant droit a deduction)</p>
      </div></td>
      <td width="111" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10">MONTANT TOTAL</div></td>
	  <td width="111" bgcolor="#fff" style=" border-width:2px; border-style:solid; border-color:red;width:100%; " ><div align="center" class="Style10">MONTANT DE LA TAXE DEDUCTIBLE</div></td>
	  
    </tr>
    <?php
  		while ($liste_etu=mysql_fetch_assoc($req)) {
			$j=$i%2;

  ?>
    <tr bgcolor=#33FFFF>
 
      <td bgcolor="#F2D113"><?php echo $liste_etu['date_impos'] ?></td>
      <td bgcolor="#F2D113"><?php echo $liste_etu['noms'] ?></td>
      <td bgcolor="#F2D113"><?php echo $liste_etu['ncc'] ?></td>
      <td bgcolor="#F2D113"><?php echo $liste_etu['ref_facture'] ?></td>
      <td bgcolor="#F2D113"><?php echo $liste_etu['natur_bien'] ?></td>
      <td bgcolor="#F2D113"><?php echo $liste_etu['montant_total'] ?></td>
	  <td bgcolor="#F2D113"><?php echo $liste_etu['mont_tax_deduct'] ?></td>
	 
    </tr>
    <?php
  }
  ?>
  </table>
</fieldset>
</div>
</div>
</div>
</body>
</html>


et ensuite page.func.php
<?php
function creer_etat_taxation($date_impos,$noms,$ncc,$ref_facture,$natur_bien,$montant_total,$mont_tax_deduct,$code,$get_id){
if(isset($_GET['id'])) $id = urldecode($_GET['id']);

$sql = "INSERT INTO etat_taxation (id,date_impos,noms,ncc,ref_facture,natur_bien,montant_total,mont_tax_deduct,code,get_id) VALUES ('','{$date_impos}','{$noms}','{$ncc}','{$ref_facture}','{$natur_bien}','{$montant_total}','{$mont_tax_deduct}','{$code}','{$id}')";
  mysql_query($sql);
 return $sql;
}
?>
0
BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 103
8 oct. 2013 à 15:19
N'oublie pas d'indiquer le problème comme "Résolu" si c'est bien le cas ;)
0
Rejoignez-nous