-
Notifications
You must be signed in to change notification settings - Fork 0
/
traitement.php
58 lines (41 loc) · 874 Bytes
/
traitement.php
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
<?php
session_start();
//echo $_GET["id"];
if(!isset($_SESSION['panier']))
{
$_SESSION['panier'] = array();
}
$isid=false;
$keyArticle=0;
foreach ($_SESSION['panier'] as $key => $article)
{
// echo "TEST ";var_dump ( $article[0]); var_dump ( $_GET["id"]);echo "<br><br><br><br>";
if($_GET["id"]==$article[0])
{
$isid = true;
$keyArticle=$key;
}
}
if($isid==false)
{
array_push($_SESSION['panier'],array($_GET["id"],1));
}
else
{
$_SESSION['panier'][$keyArticle][1]++;
}
var_dump($_SESSION['panier']);
$a= NbrArticles();
$_SESSION['nbr']= $a;
//session_destroy();
header("Location: page.php");
function NbrArticles()
{
$total=0;
foreach ($_SESSION['panier'] as $key => $article)
{
$total +=$article[1];
}
return $total;
}
?>