-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddstock.php
More file actions
55 lines (44 loc) · 1.54 KB
/
addstock.php
File metadata and controls
55 lines (44 loc) · 1.54 KB
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
<?php
include 'dbConfig.php';
if(isset($_GET['count'])){
$count = $_GET['count'];
$business = $_GET['business'];
$serial = array();
$category = array();
$brand = array();
$model = array();
$cp = array();
$mp = array();
$tax = array();
$availability = array();
for($i = 1 ; $i <= $count ; $i++)
{
array_push($serial, $_GET['serial'.$i]);
array_push($category, $_GET['category'.$i]);
array_push($brand, $_GET['brand'.$i]);
array_push($model, $_GET['model'.$i]);
array_push($cp, $_GET['cp'.$i]);
array_push($mp, $_GET['mp'.$i]);
array_push($tax, $_GET['tax'.$i]);
array_push($availability, $_GET['status'.$i]);
}
$values = '';
for($i = 0; $i < $count; $i++)
{
if($count == 1)
$values="('$serial[$i]', '$category[$i]', '$brand[$i]', '$model[$i]','$business', '$cp[$i]', '$mp[$i]','$tax[$i]', '$availability[$i]')";
else if($i<$count-1)
$values.="('$serial[$i]', '$category[$i]', '$brand[$i]', '$model[$i]','$business', '$cp[$i]', '$mp[$i]','$tax[$i]', '$availability[$i]'),";
else if($i<$count)
$values.="('$serial[$i]', '$category[$i]', '$brand[$i]', '$model[$i]','$business', '$cp[$i]', '$mp[$i]','$tax[$i]', '$availability[$i]');";
}
$query = "INSERT INTO product(serial_number,category,brand,model,business,cp,mp,tax,availability) VALUES";
$query_final = $query.$values;
echo $query_final;
$result = $conn->query($query_final);
if($result === TRUE)
{
header("location: stock.php");
}
}
?>