je suis en debutant en php et fait un stage quelqu'un aider pour le terminer le projet
table article(id_art,nomart,qteart,date_achat,qte_rest)
table commande(id_com,qtecom,date,#id_artc)
comment fait lorsque en ajoute un nouveau article de meme nom pour faire l'addition de quantite des articles de meme nom
et merçi
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
    //A faire avan toute chose,
    //pas besoin de connexion si les données sont vide
    if (empty($_POST['nomart']) || empty($_POST['qteart']) ||  empty($_POST['date_achat'])) {
        echo "<script language='javascript'> alert('champs vides') ; window.location= 'article.php'</script>";
    } else {
        include("connection.php");
        if (isset($_GET['id_art']) && $_GET['id_art'] == $_POST['id_art']) {
            $req="UPDATE article SET qteart=qteart + '".intval($_POST['qteart'])."' WHERE id_art='".$_POST['id_art']."'" ;
        } else {
            $req="insert into article values('".$_POST['id_art']."','".$_POST['nomart']."','".$_POST['qteart']."',NOW(),'".$_POST['qte_rest']."')";
        }
        $res = mysql_query($req) or die(mysql_error());
        header("Location: article.php" );
        exit; //sécurité
    }
 
?>
pour article.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php 
session_start();
?>
 
<!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>Reservation</title>
 
 
  	<link rel="stylesheet" href="css/zerogrid.css">
 
	<link rel="stylesheet" href="css/style1.css">
	<link rel="stylesheet" href="css/responsiveslides.css">
	<link href="style/style.css" rel="stylesheet" type="text/css" />
	<script src="js/jquery-latest.min.js"></script>
	<script src="js/script.js"></script>
    <script src="js/jquery183.min.js"></script>
    <script src="js/responsiveslides.min.js"></script>
    <script>
 
	</script>
 
 
<!--sa calendar-->
 
        <link href="css/demo.css"       rel="stylesheet" type="text/css" />
        <link href="css/datepicker.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="JavaScript1.2" src="account/menu/stmenu.js"></script>
<script type="text/javascript">
 
</script>
 
<!--sa error trapping-->
<script type="text/javascript">
function validateForm()
{
if(document.form.id_art.value=="")
{alert("entrer votre numero");
return false;}
 
if(document.form.nomart.value=="")
{alert("entrer votre nom");
return false;}
if(document.form1.qteart.value=="")
{alert("entrer le quantite");
return false;}
 
var x=document.form["index"]["start"].value;
if (x==null || x=="")
  {
  alert("enter la date(click the calendar icon)");
  return false;
  }
  if(document.form.qte_rest.value=="")
{alert("entrer votre quntite");
return false;}
 
}
</script>
 
 
<!--sa galerry nga css-->
<link rel="stylesheet" href="css/style.css" />
 
<!--sa poip up-->
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
  <script src="src/facebox.js" type="text/javascript"></script>
 
<style type="text/css">
 
</style>
</head>
 
 
 
 
<body>
 
 
 
 
 
 
 
	<div class="auto-style5">
 
 
  <div >
	  <div align="center" style="padding-top: 7px; font-size:24px;"><strong>RESERVATION</strong></div>
 
	<form id="form" name="F" method="post" action="newarticle.php" onSubmit="return validateForm()">
 
 
<table width="400" border="0" bgcolor="#99CCFF" align="center">
 
  <tr><th align="left"><strong>Nom de l'article</strong></th>
  <td><input type="text" name="nomart"></td></tr>
<tr><th align="left"><strong>Quantité</strong></th>
 <td><input type="text" name="qteart"></td></tr>
 <tr><th align="left"><strong>date de mise en stock :</label></td>
              <td><input type="date" id="date" name="date_achat" required></td></tr>
 
 
 <tr><td colspan="3" bgcolor="#A9D0F5" align="center"><input type="submit" value="Enregistrer">&nbsp;&nbsp;</td>
 
</table>
</form>
 
</div>
 
 
 
</div>
<?php
 
?>
 
<div class="footer" style="text-align:center; font-family:Arial, Helvetica, sans-serif; font-size:12px;"></div>
<script type="text/javascript" src="compressed.js"></script>
<script type="text/javascript">
	$('slideshow').style.display='none';
	$('wrapper').style.display='block';
	var slideshow=new TINY.slideshow("slideshow");
	window.onload=function(){
		slideshow.auto=true;
		slideshow.speed=4;
		slideshow.link="linkhover";
		slideshow.info="information";
		slideshow.thumbs="slider";
		slideshow.left="slideleft";
		slideshow.right="slideright";
		slideshow.scrollSpeed=4;
		slideshow.spacing=4;
		slideshow.active="#fff";
		slideshow.init("slideshow","image","imgprev","imgnext","imglink");
 
</script>
 
<form>
<center>
<div id="foot">
<table border bgcolor="teal"   />
<colgroup span="3" width="150" align="center" bgcolor="lightblue" >
 
      <tr>
	   <th>numero</th>
        <th>nom</th>
		<th>quantite</th>
        <th>date mise en stock</th>
          <th>quantite restante</th>
	      </tr>
 
 
		  </colgroup>
    <?php
include("connection.php");
$reqt=mysql_query("select * from `article` " );
while($row=mysql_fetch_array($reqt))
{
	$id_art=$row[0];
$nomart=$row[1];
$qteart=$row[2];
$date_achat=$row[3];
$qte_rest=$row[4]
?>
 
 
 
	   <tr>  <td><?php echo"$id_art";?></td>
        <td><?php echo"$nomart";?></td>
        <td><?php echo"$qteart";?></td>
       <td><?php echo"$date_achat";?></td>
	   <td><?php echo"$qte_rest";?></td>
		<td><?php echo"<a href=supprime_art.php?nomart=$nomart><img src='images/slider/sup.png'></a>"; ?></td>
		<td><?php echo"<a href=modifier_art.php?nomart=$nomart><img src='images/slider/mod.png'></a>"; ?></td>
		</tr>
 
    <?php }?>
</table>
	</right>
 
 
 
 
</div>
 
</center>
 
</form>
 
<p> <span id="type6"></span></p>
 
 
</body></html>