Php mysql

med -  
yvau Messages postés 17 Statut Membre -
Bonjour,
dans mon code php ci dessous je veut enregistrer dans la table mensuration
code employé,code famille et la valeur du taille il n'y a pas d'erreur dans le code
mais l'enregistrement dans la table mensuration n'a pas effectué correctement
<H1>DEMANDE DE PRIME </H1>
<H1> </H1>
<DIV class="basicMain">
<DIV id="main" class="clearfix">

<H2 class="h4">Fiche de mensuration </H2>
<DIV class="simpleRoundedBox softBox">
<DIV class="preview clearfix">
<DIV class="pics"><A href="" title="Télécharger BurnAware Free Edition"></A></DIV>

<DIV class="infos">
<H3 class="h4"><A href="" title="Télécharger BurnAware Free Edition">Empolyer </A></H3>
<table width="350" height="126" border="0" align="center" cellpadding="0">
<tr>
<?
$reu=mysql_query("SELECT * FROM employer WHERE matricule=".$_GET["matr"]);
$lig=mysql_fetch_array($reu);
?>

<th width="164" scope="col"><div align="right" class="Style9">Matricule</div></th>
<th width="180" scope="col"> <? echo $_GET["matr"]; ?></th>

</tr>
<tr>
<th scope="col"><div align="right" class="Style9">Nom</div></th>
<th scope="col"> <? echo $lig[3]; ?></th>
</tr>
<tr>
<th scope="col"><div align="right" class="Style9">Prénom</div></th>
<th scope="col"> <? echo $lig[4]; ?></th>
</tr>
<tr>
<th scope="col"><div align="right" class="Style9">Numer CIN </div></th>
<th scope="col"> <? echo $lig[5]; ?></th>
</tr>
<tr>
<th scope="col">
<? $r2=mysql_query("select * from fonction where code_fct=".$lig[2]);
$rst=mysql_fetch_row($r2);
?>
<div align="right" class="Style9">Fonction</div></th>
<th scope="col"> <? echo $rst[1]; ?></th>
</tr>

<tr>
<th scope="col"><div align="right" class="Style9">Adresse</div></th>
<th scope="col"> <? echo $lig[6]; ?></th>
</tr>
</table>
</DIV>
</DIV>
<p><A href="" title="Télécharger RealPlayer"></A><UL class="listing"><LI>
<div align="left"><A href="" title="Télécharger Yahoo! Messenger" class="Style4">Liste des articles </A></div>
</LI>
</UL>
<DIV class="seeAll">
<DIV class="seeAll">
<DIV class="seeAll">
<form name="f1" method="post" action="<? echo($_SERVER['PHP_SELF']); ?>">
<table width="634" height="55" align="center" border="1">
<tr bgcolor="#66CC00">
<th width="216" height="23" align="center" scope="col"><div align="center">Article</div></th> <input type="hidden" name="code" value="<? echo $_GET["matr"]; ?>">
<th width="267" scope="col" align="center"><div align="center">taille/pointure</div></th>
</tr>
<? $sql=("select * from familleart ");
$res=mysql_query($sql);
?>
<?
while(@$ligne=mysql_fetch_row($res))
{
?>
<tr>
<th height="24" scope="row"><span class="Style3"><? echo $ligne[1]; ?></span></th>
<td>
<div align="center">
<? $r2=mysql_query("select * from taille where cod_f=".$ligne[0]);
?>
<select name="taille" class="input-text">
<option value=""></option>
<?php while($t=mysql_fetch_row($r2))
{$id1=$t[0];
$lib=$t[1];
print "<option value=" . $id1 . ">" . $lib . "</option>";

?>
<?php }?>
</select>
</div></td>
<td width="135" >
<div align="center">
<input type="submit" name="valid" value="valider" />
</div></td>
</tr>

<?php
if(isset($_POST["valid"]))
{
$requetee="insert into mensuration values
('".$_POST["code"]."','".$ligne[0]."','".$_POST["taille"]."')" ;
if(mysql_query($requetee))
echo "<b>Ajout effectué</b>";
else
echo "<font color=#FF0000 ><b>Problème d'ajout, veuillez réessayer</b></font>";
}
?>
<? } ?>
</table>
</form>

<table width="500" height="40" border="0" cellpadding="0" align="center">
<tr>

<th scope="col"><form id="form3" name="form3" method="post" action="">

<div align="center">
<input type="submit" name="Submit2" value="Terminer" />
</div>
</form></th>
</tr>
</table>
A voir également:

2 réponses

Utilisateur anonyme
 
ta requête est mal formulé
0
yvau Messages postés 17 Statut Membre 1
 
Bonjour med,
faudrait mettre ce genre de balise <?php plutôt que celle-ci <? quand tu code
j'ai pas tout vue le code mais comme la dit maxime71500 la requete est mal formulé.
En général on met les champs avant les valeurs
exemple
 
<?php
$requetee = mysql_query ("insert into mensuration(`champ1`, `champ2`, `champ3` )  values ($valeur1, $valeur2, $valeur3)");
?>

fais un tour sur le site developpez.com
ça pourra t'aider a progresser

https://sylvie-vauthier.developpez.com/tutoriels/php/grand-debutant/
0