-
Notifications
You must be signed in to change notification settings - Fork 2
/
adddevice.php
160 lines (132 loc) · 5.44 KB
/
adddevice.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
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<div class="topnav">
<a href="images/logo.png">
<img src="images/logo.png" alt="NTPC logo" class="logopic">
</a>
<a class="nav-item nav-link" href="index.php">Home</a>
<a class="nav-item nav-link " href="addemployee.php">Add Employee</a>
<a class="nav-item nav-link" href="adddevice.php">Add Device</a>
<a class="nav-item nav-link" href="issue.php">Issue</a>
<a class="nav-item nav-link" href="return.php">Return</a>
<a class="nav-item nav-link" href="report.php">Report</a>
</div>
<head>
<meta charset="utf-8">
<title>Index</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link href="dashboard.css" rel="stylesheet" type="text/css" >
</head>
<body style = "padding:10px;">
<!-- <br>
<nav class="nav nav-pills nav-justified">
<a class="nav-item nav-link" href="index.php">Home</a>
<a class="nav-item nav-link" href="addemployee.php">Add Employee</a>
<a class="nav-item nav-link active" href="adddevice.php">Add Device</a>
<a class="nav-item nav-link" href="issue.php">Issue</a>
<a class="nav-item nav-link" href="return.php">Return</a>
</nav>
<br> -->
<br>
<br>
<div >
<!-- start -->
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-0"></div>
<div class="col-lg-6 col-md-6 col-sm-10">
<div class="card">
<div class="container">
<form action="adddevice.php" method="post">
<h1 align="center">Update Devices</h1>
<h6 class="card-subtitle mb-2 text-muted" align="center">Device Issue and Return System</h6><br>
<br>
<div>
<div>
<label style="width: 40%">Company</label>
<input style="width: 50%" type="text" name="company" value="" placeholder="Enter Company">
</div>
<!-- <label style="width: 40%">Company </label>
<select style="width: 50%" name="company" type="text">
<option >Company</option>
<option value="HP">HP</option>
<option value="Lenevo">Lenevo</option>
<option value="Dell">Dell</option>
<option value="Dell">Apple</option>
</select> -->
<br>
<!-- <br>
<label style="width: 40%">Type of device </label>
<select style="width: 50%" name="type" type="text">
<option >Item type</option>
<option value="Laptop">Laptop</option>
<option value="Printer">Printer</option>
<option value="Keyboard">Keyboard</option>
<option value="Hard Disk">Hard Disk</option>
</select> -->
<div>
<label style="width: 40%">Type</label>
<input style="width: 50%" type="text" name="type" value="" placeholder="Enter type">
</div>
<div>
<br>
<input type="checkbox" name="returnable" value=1> Is it returnable<br>
</div>
<div>
<br>
<button class="btn btn-primary" type="submit" name="submit" value="Add Device">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-0"></div>
</div>
</div>
<!-- end -->
<!-- <h2>Add Device</h2>
<form action="adddevice.php" method="post">
<input type="text" name="company" value="" placeholder="company">
<input type="text" name="type" value="" placeholder="type">
<label>Is it returnable</label>
<input type="checkbox" name="returnable" value=1>
<input type="submit" name="submit" value="Add Row">
</form> -->
<?php
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = 'test';
$conn = mysqli_connect($servername, $username, $password, $dbname);
if($conn){
//TO INSERT DATA
if(isset($_POST['submit'])){
$company = $_POST['company'];
$type = $_POST['type'];
$returnable = isset($_POST['returnable']) ? "Yes" : "No";
$res2 = mysqli_query($conn, "INSERT INTO `Device`(`Company`, `Type`, `Available`, `Returnable`) VALUES ('$company', '$type', 'Yes', '$returnable') ");
if($res2){
echo "Data entered in database successfully";
}
else{
echo "Some error occured while entering the data in database";
}
}
//TO FETCH DATA
$res = mysqli_query($conn, "SELECT * FROM Device ORDER BY DeviceNo");
if(mysqli_num_rows($res)){
$x = mysqli_fetch_all($res);
// echo "<h2>Database</h2>";
echo "<div class='card'> <div class='container'> <h2>Database</h2>
<table class='table table-hover' > <thread> <tr><th>Device No</th> <th>Company</th> <th>Type</th> <th>Available?</th> <th>Returnable?</th> </tr> </thread>";
for($i = 0; $i < sizeof($x); $i++){
print_r('<tr>'.'<td>'.$x[$i][0].'</td>'.'<td>'.$x[$i][1].'</td>'.'<td>'.$x[$i][2].'</td>'.'<td>'.$x[$i][3].'</td>'.'<td>'.$x[$i][4].'</td>'.'</tr>');
}
echo "</table></div></div>";
}
}
echo "</div>";
echo "</body>";
echo "</html>";
?>