Php sql (ajout)

Fermé
med - 22 déc. 2009 à 23:02
avion-f16 Messages postés 19246 Date d'inscription dimanche 17 février 2008 Statut Contributeur Dernière intervention 21 avril 2024 - 23 déc. 2009 à 00:07
Bonsoir,
SVP je veut réaliser un ajout dans la base avec cette formulaire :
<form name="AFF" method="post" action="<? echo($_SERVER['PHP_SELF']); ?>">
<span class="Style3">
<label><span class="Style3">
<label>
</label>
<label>
</label>
<div align="center">
<table width="419" height="277" border="0">
<tr>
<input type="hidden" name="emplyé" value="<? echo $_GET["emp"]; ?>" />
<? $matre=$_GET["emp"];
$rr2=mysql_query("select * from employer where matricule=".$matre);
$rst2=mysql_fetch_row($rr2);
?>
<td width="106" height="47"><div align="right" class="Style3">Employé :</div></td>
<td width="27" class="bisTitle"><div align="left"><? echo $rst2[3]; ?> </div>
<div align="right"></div><div align="right"></div></td>
<td width="400" class="bisTitle"><? echo $rst2[4]; ?></td>
<input type="hidden" name="code" value="<? echo $_GET["emp"]; ?>">
<input type="hidden" name="nom" value="<? echo $_GET["nom"]; ?>">
<input type="hidden" name="pren" value="<? echo $_GET["prenom"]; ?>">
</tr>


<tr>
<td width="106" height="47">
<div align="right">
<? $r2=mysql_query("select * from fonction where code_fct=".$rst2[2]);
$rst=mysql_fetch_row($r2);
?>
<span class="Style3">fonction :</span></div></td>
<td colspan="2" class="bisTitle"><? echo $rst[1]; ?></td>
<input type="hidden" name="fct" value="<? echo $rst[1]; ?>">
</tr>
<tr>
<td width="106" height="47">
<div align="right">
<? $r2=mysql_query("select t.* from tenue t,foction_tenu ft where t.code_t=ft.code_t and ft.code_fct=".$rst2[2]);
?>
<span class="Style3"> tenue</span></div></td><td colspan="2">
<select name="tenue" class="input-text" onChange="javascript : modifcombo()"> <option value=""></option>
<?php while($t=mysql_fetch_row($r2))
{$id1=$t[0];
$lib=$t[1];
print "<option value=" . $id1;
if ($id1 == $tenue)
print " selected";
print ">" . $lib . "</option>";
?>
<?php }?>
</select> </td>
</tr>
<tr>
<td width="106" height="44" class="Style3">
<div align="right">date :</div></td>
<td colspan="2"><input type="text" name="dat" id="dateinput"/></td></tr>

<tr><td colspan="3">
<table width="543" height="63" border="2" cellpadding="10" align="center">
<tr bgcolor="#66CC00">
<td height="20">article</td>
<td>nbre</td>
<td>taille</td>
</tr>
<?
$ma_requ = "SELECT sf.*,c.nbre FROM sous_fam_art sf,composition c WHERE sf.code=c.code and c.code_t=".$tenue;
$reu=mysql_query($ma_requ);
?>
<? while(@$lig=mysql_fetch_row($reu))
{
?>
<tr>
<td> <? echo $lig[2]; ?></td>
<td> <? echo $lig[3]; ?></td>
<input type="hidden" name="nbr" value="<? echo $lig[3]; ?>"/>
<td>
<? $req=mysql_query("select * from article where code=".$lig[0]." and taille =(select valeur from mensuration where matricule=".$_GET["emp"]." and cod_f=".$lig[1].")");
$rste=mysql_fetch_array($req);
?>
 <? echo $rste[2]; ?></td>
<input type="hidden" name="art" value="<? echo $rste[0]; ?>"/>
<input type="hidden" name="tail" value="<? echo $rste[1]; ?>"/>
</tr>
<? } ?>
</table>
</td></tr>
<tr>
<div align="center">
<td height="47" colspan="3">
<div align="center">
<input type="submit" name="enr" value="enregistrer" />
<a href="g.php"><input type="submit" name="Submit2" value="Annuler" /></a>
</div></td>
</div>
</tr></table>
</div>

</form>
je veut que pour chaque ligne de la table qui contient (article, nbre, taille) exécuter un enregistrement dans la table détail par la requête ci dessous
<?
$requetee="insert into détail values
('".$_POST["codem"]."','".$rst[0]."','".$_POST["dat"]."','".$rste[0]."','".$rste[1]."','".$lig[3]."','instance')" ;
if(mysql_query($requetee))

echo "<font color=#00FF00 ><b>Ajout effectuer</b></font>";
else
echo "<font color=#FF0000 ><b>Problème d'ajout, veuillez réessayer</b></font>";

?>
aide mois s'il vous plaie
A voir également:

1 réponse

avion-f16 Messages postés 19246 Date d'inscription dimanche 17 février 2008 Statut Contributeur Dernière intervention 21 avril 2024 4 500
23 déc. 2009 à 00:07
Le problème ?
Commence déjà par remplacer les "<?" par "<?php".
0